WorksheetsOperators in Python
Total questions: 43
Worksheet time: 22mins
print(7//2)
2
3
4
print(9>2 and 6<=6)
TRUE
FALSE
print(8!=8)
TRUE
FALSE
print(2**3)
6
12
8
print((15%4))
4
5
3
print("3"+"3")
33
6
INVALID OUTPUT
print(not (0<1))
TRUE
FALSE
TYPE ERROR
print(2%2==0 or 3%2==0)
TRUE
FALSE
INVALID OUTPUT
print(5+8*2)
26
21
169
print(4+"2")
6
42
TYPE ERROR
What is the value of the expression 100 / 25?
4
4.0
"4.0"
'4.0'
x = 5
y = 3
print(x == y)
True
False
x = 5
y = 3
print(x != y)
True
False
x = 5
x%=3
print(x)
2
2.0
3
3.0
From logical operators
<<
is not
not in
not
From assignment operators
>>=
==
is
in
From arithmetic operators
/=
//
and
&
From comparison operators
>>
>=
=
is
From identity operators
==
in
is
=
From membership operators
=
not in
is
!=
From bitwise operators
is not
-
not
~
xy
x^^y
x^y
x**y
x pow y
10%3
3
1
9
10
10//3
3
3.3
0.3
3.0
x = x ^ 3 can also be written as
x = x pow 3
x = x ** 3
x = x XOR 3
x ^= 3
the output of: x >= y
Adjust x so that it is greater than or equal y
True if x is greater than or equal y
x is shifted y bits to the right
False if x equals y in value
x = 5
print(not(x > 3 and x < 10))
not(x > 3 and x < 10)
True
False
syntax error
What is the output of:
b=2
c=2
print(b is c)
c +=2
print(b is c)
False
False
False
True
True
False
True
True
What is the output of:
print (7&8)
print (7|8)
print (7^8)
print (7>>3)
0
15
15
0
0
15
15
224
0
15
0
0
0
0
15
0
print(5+8*2)
26
21
169
Look at the following code:
age = "23"
age = age + 1
print (age)
What is the result of this code?
23
24
23 + 1
an error message
Look at the following code:
age = input ("What is your age? ")
age = age + 1
print (age)
If the user inputs 23, what is the result of the code?
23
24
age
an error message
Look at the following code:
age = int(input ("What is your age? "))
age = age + 1
print (age)
If the user inputs 23, what is the result of the code?
23
24
age
an error message
Look at the following code:
age = input ("What is your age? ")
age = int(age) + 1
print (age)
If the user inputs 23, what is the result of the code?
23
24
age
an error message
Look at the following code:
age = input ("What is your age? ")
age = int(age + 1)
print (age)
If the user inputs 23, what is the result of the code?
23
24
age
an error message
Look at the following code:
Length = 50
Width = 30
Area = Length * Width
print (Area)
What is the result of this code?
Area
50
150
an error message
Look at the following code:
Length = 50
Width = 30
Area = L * W
print (Area)
What is the result of this code?
Area
50
150
an error message
Look at the following code:
L = 50
W = 30
Area = L * W
print ("Area")
What is the result of this code?
Area
50
150
an error message
Who developed python?
Ritchie
Bill gates
Guido van Rossum
Sunder
In Python script editor, the errors will be shown in ----- color in the IDLE window?
green
black
red
orange
Which is known as simple assignment operator?
==
=
+=
#
Python uses ------ to define program blocks.
whitespace
delimiter
escape sequence
curly braces
Which function accepts all data as string or characters but not as numbers?
int()
output()
input()
print()
