Python Editor

Python | Lesson 1 | Operators


#Arithmetic operators ( +, -, *, /, %, **, //)
print ( 30 + 50)
print (5 %2)
print (4**3)

#Assignment operators (=, +=, -=, *=, /=,%=, //=, **=, &=, !=,^=,>>=,<<=)

x -=4
print (x)
y *=10
print (y)
z /=50
print(z)

#Comparison operators (==, !=, >, <, >=, <= )

a =10
b =20
if ( a == b)
   print ("a and b are not equal")

#Logical operators ( and, or, not )
a = 10
b = 5
print ( a>10 and b< 6)

#Identity operators ( is, is not)

#Membership operators ( in, not in)

x=[10,20]
print ( 10 in x)

#Bitwise operators ( &, |, ^, ~, <<, >>)

a=5
b=6
print ( a & b)

3 comments:

  1. Replies
    1. There is a syntax error. add the ")" at the end. print ("My first Program")

      Delete
  2. #Rohan
    a=10.44564767567
    b=20.234234342

    x=5
    y=10

    print( 2 * x + 3 *y)



    if 1 > 3:

    print("10 is greater than 3")

    print("end")

    ReplyDelete