next


Python Online Compiler

Hello World Program
Unary Operators

def Hello():
    print("Welcome To Hello World")


#Function Calling
Hello()
OUTPUT: Welcome To Hello World

UnaryMinus

def Rain():
    x=24;
    print("The Sign value is ",-x)

#Function Calling
Rain()
OUTPUT: the sign value is -24

Addition Of Two numbers
Binary Operators

def Rain():
    x=12;
    y=12;
    z=x+y;
    print("Addtion is ",z)

#Function Calling
Rain()
OUTPUT: Addition Of Two Numbers Is 24

All Arithmetic Operations
Arithmetic Operators

def Rain():
    x=12;
    y=12;
    print("Addtion is ",x+y)
    print("Subtraction  is ",x-y)
    print("Multiplication is ",x*y)
    print("Division is ",x/y)
    print("Modulus  is ",x%y)
    print("Floor division  is ",x//y)
    print("Exponent  is ",x**y)
 
#Function Calling
Rain()

OUTPUT: Addtion is 24 Subtraction is 0 Multiplication is 144 Division is 1.0 Modulus is 0 Floor division is 1 Exponent is 8916100448256

Relational Operators
Relational Operators

def Rain():
    x=12;
    y=12;
    print("== is ",x==y)
    print(">  is ",x>y)
    print("< is ",x<y)
    print(">= is ",x>=y)
    print("<=  is ",x<=y)
    print("!= is ",x!=y)
#Function Calling
Rain()
OUTPUT: == is True > is False < is False >= is True <= is True != is False

Relational Operators With Using Third Variable

def Rain():
    x=12;
    y=12;
    z=x>y
    print("The  X and Y Relation is",z)
#Function Calling
Rain()
OUTPUT: The X and Y Relation is false

Logical Operators
Logical Operators


def Rain():
    x=12;
    y=24;
    z=16;
    print("Logical AND  is ",x>y and x>z)
    print("Logical AND   is ",x>y or x>z)
    print("Logical AND  is ",not(x>y and x>z))
   
#Function Calling
Rain()
OUTPUT: Logical AND is False Logical AND is False Logical AND is True

Logiccal Operators Without Using Third Variable

def Rain():
    x=12;
    y=24;
    z=16;
    print("Logical AND  is ",x>y and x>z)
    print("Logical OR   is ",x>y or x>z)
    print("Logical NOT  is ",not(x>y and x>z))
   
#Function Calling
Rain()
OUTPUT: Logical AND is false Logical OR is false Logical NOT is true

Bitwise Operators
Bitwise Operators

    def Rain():
        x=10;
        y=15;
        print("Bitwise And is ",x&y)
        print("Bitwise OR is ",x|y)
        print("Bitwise CAP is",x^y)
        print("Bitwise Left Shift is ",x<<<y)
        print("Bitwise Right Shift is",x>>y)
        print("Bitwise Nagetion is",~x)
    
    #Function Calling
    Rain()
    
OUTPUT: Bitwise And is 10 Bitwise OR is 15 Bitwise CAP is 5 Bitwise Left Shift is 40 Bitwise Right Shift is 2 Bitwise Nagetion is -11

Swaping Of Two Numbers With Using Third Variable
Assignmrnt Operators

def Rain():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))
    
    z=x
    x=y
    y=z
    print("x value is ",x ," y value is ",y)

#function Calling
Rain()

OUTPUT: Enter x Value12 Enter y Value24 x value is 24 y value is 12

Swaping Of Two Numbers Without Using Third Variable

def Rain():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))
    
    x=x+y
    y=x-y
    x=x-y
    print("x value is ",x ," y value is ",y)

#function Calling
Rain()
OUTPUT: Enter x Value12 Enter y Value24 x value is 24 y value is 12

Max Number Program Using Ternary Operator
Ternary Operator

def Rain():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))
    
    z="x is Max" if x>y else "y is Max" 
    print(z)   

#function Calling
Rain()

OUTPUT: Enter x Value12 Enter y Value24 y is Max

ODD or Even Number Program Using Ternary Operator

def Rain():
    x=int(input("Enter x Value"))
    
    y="Even" if x %2==0 else "Odd" 
    print(y)   

#function Calling
Rain()
OUTPUT: Enter x Value24 Even

ODD or Even Number Program Using IF ELSE Condition
Conditional

def Rain():
    x=int(input("Enter x Value"))
    if(x%2==0):
        print("Even Number")
    else:
        print("Odd Number")

#function Calling
Rain()

OUTPUT: Enter x Value24 Even Number

Max Number Program Using IF ELSE Condition

def Rain():
    x=int(input("Enter x Value"))
    y=int(input("Enter y Value"))
    if(x>y):
        print("x is Max")
    else:
        print("y is Max")

#function Calling
Rain()

OUTPUT: Enter x Value12 Enter y Value24 y is Max

Vowel & Consonant Program Using IF ELSE Condition

def Rain():
    ch=input("Enter Character")
    if(ch=='a' or ch=='e' or ch=='i'or ch=='o'or ch=='u'or ch=='A'or ch=='E'or ch=='I'or ch=='O'or ch=='U'):
        print("Vowel")
    else:
        print("Consonant")

#function Calling
Rain()

OUTPUT: Enter CharacterA Vowel