wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

Python Quiz-2 operators BF

Total questions: 119

Worksheet time: 3hrs 33mins

Name
Class
Date
1.

print(7//2)

a)

2

b)

3

c)

4

2.

print(9>2 and 6<=6)

a)

TRUE

b)

FALSE

3.

print(8!=8)

a)

TRUE

b)

FALSE

4.

print(2**3)

a)

6

b)

12

c)

8

5.

print((15%4))

a)

4

b)

5

c)

3

6.

print("3"+"3")

a)

33

b)

6

c)

INVALID OUTPUT

7.

print(not (0<1))

a)

TRUE

b)

FALSE

c)

TYPE ERROR

8.

print(2%2==0 or 3%2==0)

a)

TRUE

b)

FALSE

c)

INVALID OUTPUT

9.

print(5+8*2)

a)

26

b)

21

c)

169

10.

print(4+"2")

a)

6

b)

42

c)

TYPE ERROR

11.

What is the value of the expression 100 / 25?

a)

4

b)

4.0

c)

"4.0"

d)

'4.0'

12.

x = 5

y = 3


print(x == y)

a)

True

b)

False

13.

x = 5

y = 3


print(x != y)

a)

True

b)

False

14.

x = 5


x%=3


print(x)

a)

2

b)

2.0

c)

3

d)

3.0

15.

What does the following comparison operator “==” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

16.

What does the following comparison operator “!=” represent in Python programming?

a)

Equal to

b)

Assignment

c)

Allocation

d)

Not equal to.

17.

What does the following comparison operator “>” represent in Python programming?

a)

Equal to

b)

Greater than

c)

Less than

d)

Not equal to.

18.

What does the following comparison operator “<” represent in Python programming?

a)

Equal to

b)

Greater than

c)

Less than

d)

Not equal to.

19.

What does the following comparison operator “>=” represent in Python programming?

a)

Greater than

b)

Greater than or equal to

c)

Greater than and equal to

d)

Less than or equal to

20.

What does the following comparison operator “<=” represent in Python programming?

a)

Greater than

b)

Greater than and equal to

c)

Less than

d)

Less than or equal to

21.

What is the name of the following logical operator?

Returns True if both statements are true

(a)  

22.

What is the name of the following logical operator?

Returns True if one of the statements is true

(a)  

23.

What is the name of the following logical operator?

Reverses the result, returns False if the result is True

(a)  

24.

What is the result of the following condition if x = 3?

not(x < 5 and x < 10)

a)

True

b)

False

25.

What is the result of the following condition if:

A = 30

B = 21

C = 71

(A > B and A > C) or B < C

a)

True

b)

False

26.

What is the result of the following condition if:

A = 30

B = 21

C = 71

not(B < A and B < C)

a)

True

b)

False

27.

What is the result of the following condition if:

A = 30

B = 21

C = 71

B != A or C < A

a)

True

b)

False

28.

Which of these is not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

29.

What is the output of the following code :

print 9//2

a)

4.5

b)

4.0

c)

4

d)

Error

30.

Who developed the Python language?

a)

Zim Den

b)

Guido van Rossum

c)

Niene Stom

d)

Wick van Rossum

31.

Which one of the following is the correct extension of the Python file?

a)

.python

b)

.p

c)

.py

d)

None of these

32.

Which of the following declarations is incorrect?

a)

_x = 2

b)

__x = 3

c)

__xyz__ = 5

d)

None of these

33.

Which of the following declarations is incorrect in python language?

a)

xyzp = 5,000,000

b)

x y z p = 5000 6000 7000 8000

c)

x,y,z,p = 5000, 6000, 7000, 8000

d)

x_y_z_p = 5,000,000

34.

What will be the output of this statement?

>>>"a"+"bc"

a)

a+bc

b)

a bc

c)

abc

d)

a

35.
What is the output from the following code?print ("hello world")
a)
Hello World
b)
hello world
c)
print hello world
36.
What will the output be from the following code?
print("3+4")
a)
7
b)
3+4
c)
34
d)
SyntaxError
37.
Why do we use variables in programming?
a)
edit data
b)
store data
c)
integer
d)
to look good
38.

Which of these operators means EQUAL TO?

a)

'='

b)

'=>'

c)

'<='

d)

'=='

39.
What would amount equal in this piece of code:

amount = 2 + 5 * 2
a)
12
b)
9
c)
14
d)
5
40.

What is the output of range(1,10)

a)

0123456789

b)

123456789

c)

1 to 10

d)

012345

41.

Choose the correct declaration of a float variable with the value 3.14

a)

pi = "3.14"

b)

pi = int(3.14)

c)

pi = 3.14

d)

float pi = 3.14

42.

What is the final result of the expression 4 + 5 * 3?

a)

27

b)

12

c)

19

d)

21

43.

What is the final result of the expression 7 / 3 + 6?

a)

0

b)

8.33333333

c)

8

d)

.777777777778

44.

What does the following code print?

x = 3.4

y = 1

print int(x)

print x + y

a)

3.4

4.4

b)

3

4.4

c)

3

4

d)

The code causes an error

45.

What is the final result of the expression 2**3?

a)

6

b)

8

c)

2

d)

That is not a valid Python expression.

46.

What is the operator below called?

%

a)

Exponent

b)

Modulus

c)

Divide

d)

Percent

47.

print(9//3,9/3)

a)

3 3.3

b)

3.3 3

c)

3.0 3.3

d)

3.3 3.3

48.

Valid operation?

a)

'2'-'1'

b)

'third'*'2'

c)

'sum'**3

d)

"2"+"1"

49.

What is the output of this expression, 3*1**3?

a)

3

b)

21

c)

9

d)

33

50.

print(1.1+2.2==3.3)

a)

True

b)

False

c)

Error

d)

3.3

51.

Suppose the following statements are executed:

a = 100 b = 200

What is the value of the expression a and b?

a)

200

b)

100

c)

0

d)

False

52.

What is the output of “hello”+1+2+3 ?

a)

hello123

b)

hello

c)

Error

d)

hello6

53.

str1 = "My salary is 7000"; str2 = "7000" print(str1.isdigit()) print(str2.isdigit())

a)

False True

b)

False False

c)

True False

d)

True     True

54.

print(-18//-2)

print(18//2)

print(18/2)

print(18%2)

print(str(18/2))

find output

a)

9.0

9

9.0

0

9.0

b)

9

9

9.0

0

"9.0"

c)

9

9

9.0

0

9.0

d)

9

9

9.0

0

90

55.

x = 10

y = 50

if x ** 2 > 100 and y < 100:

print(x, y)

find output

a)

NONE

b)

Error

c)

10,50

d)

100

56.

4 is 100 in binary and 11 is 1011. What is the output of the following bitwise operators?a = 4

b = 11

print(a | b)

print(a >> 2)

a)

15

0

b)

0

15

c)

15

1

d)

1

15

57.

y = 10

x = y += 2

print(x)

a)

12

b)

10

c)

0

d)

Error

58.

print(int(12.53))

print(round(12.53))

print(round(12.36,1))

a)

13

12

12.4

b)

12

13

12.4

c)

12

13

12.3

d)

error

59.

Single line comment Symbol?

a)

//

b)

/

c)

$

d)

#

60.

Choose the correct function to get the character from ASCII number

a)

 ascii(number)

 

b)

 char(number)

 

c)

chr(number)

d)

ord(number)

61.

str1 = 'Welcome'

print (str1[:6] + ' PYnative')

a)

Welcome PYnative

 

b)

WelcomPYnative

 

c)

Welcom PYnative

 

d)

WelcomePYnative

62.

The function pow(x,y,z) is evaluated as:

a)

(x**y)**z

b)

(x**y) / z

c)

(x**y) % z

d)

(x**y)*z

63.

Which one of these is floor division?

a)

/

b)

//

c)

%

d)

None of the mentioned

64.

What is the answer to this expression, 22 % 3 is?

a)

7

b)

1

c)

0

d)

5

65.

Mathematical operations can be performed on a string.

a)

True

b)

False

66.

Operators with the same precedence are evaluated in which manner?

a)

Left to Right

b)

Right to Left

c)

Can’t say

d)

None of the mentioned

67.

What is the output of this expression, 3*1**3?

a)

27

b)

9

c)

3

d)

1

68.

Which one of the following has the same precedence level?

a)

Addition and Subtraction

b)

Multiplication, Division and Addition

c)

Multiplication, Division, Addition and Subtraction

d)

Addition and Multiplication

69.

The expression int(x) implies that the variable x is converted to integer.

a)

True

b)

False

70.

Which one of the following has the highest precedence in the expression?

a)

Exponential

b)

Addition

c)

Multiplication

d)

Parentheses

71.

Which of these in not a core data type?

a)

Lists

b)

Dictionary

c)

Tuples

d)

Class

72.

What is the return type of function id?

a)

int

b)

float

c)

bool

d)

dict

73.

Find T ?

T=144 / 2 + 5 * 9 - ( 8 -3 )

a)

106

b)

688

c)

112

d)

684

74.

Find the Output:

Item = {"ECE" , "CSE" , "EEE" , "CIVIL"}

Item.add (2,"MECH")

print(Item)

a)

{ "ECE" , "MECH" , "CSE" , "EEE" , "CIVIL" }

b)

{ "ECE" , "CSE" , "MECH" , "EEE" , "CIVIL" }

c)

{ "ECE" , "CSE" , "EEE" , "CIVIL" }

d)

{ "ECE" , "CSE" , "EEE" ,"MECH" , "CIVIL" }

75.

Find the Output ?

A = "Anand Institute of higher technology"

print ( A[-5:7]

a)

_Institute of higher techn

b)

nstitute of higher technol

c)

d Institute of higher techn

d)

Institute of higher techno

76.

def.number (r1 , r2)

sum = r1 / r2

return sum

a = number (r2 = 15 , r1 = 10)

a)

2 / 3

b)

3 / 2

c)

error

d)

2

77.

what is the output of the following code ?

var1 = 1

var2 = 2

var3 = "3"


print (var + var2 var3)

a)

Error. Mixing operators between numbers and strings are not supported

b)

6

c)

33

d)

123

78.

Which of the following function convert a string to a float in python ?

a)

float(X)

b)

int(x[,base])

c)

long(X[,base])

d)

str(X)

79.

what is the output of the following programing ?

X = [ 'ab' , 'cd' ]

for i in X:

i.upper()

print (x)

a)

[ 'AB' , 'CD' ]

b)

[ 'ab' , 'cd' ]

c)

[ AB , CD ]

d)

ERROR

80.

find p ?

p = ( 35 , 46 , 73 , 21 )

p.append( -2 , 24 )

print (p)

a)

( 35 , 46 , 73 , 24 , 21 )

b)

error

c)

( 35 , 46 , 24 , 73 , 21 )

d)

( 35 , 24 , 73 , 21 )

81.

what will be the output of the following python code snippet ?

not (10 < 20) and not (10 > 30 )

a)

TRUE

b)

FALSE

82.

Find the output ?

a = True

b = False

c = False

if a or b and c :

print "INFYTQ"

else:

print "infytq"

a)

infytq

b)

INFYTQ

c)

ERROR

83.

What will be the output of the following Python code?

  1. list1 = [1, 3]

  2. list2 = list1

  3. list1[0] = 4

  4. print(list2)

a)

[1, 4]

b)

[1, 3, 4]

c)

[4, 3]

d)

[1, 3]

84.

What will be the output of the following Python code?

a)

error

b)

1 2 3 4

c)

a b c d

d)

0 1 2 3

85.

What is the order of precedence in python?

i) Parentheses
ii) Exponential
iii) Multiplication

iv) Division
v) Addition
vi) Subtraction

a)

i,ii,iii,iv,v,vi

b)

ii,i,iii,iv,v,vi

c)

ii,i,iv,iii,v,vi

d)

i,ii,iii,iv,vi,v

86.

What is the value of the following expression?

float(22//3+3/3)

a)

8

b)

8.0

c)

8.3

d)

8.33

87.

What will be the output of the following Python expression if x=15 and y=12?

x & y

a)

b1101

b)

0b1101

c)

12

d)

1101

88.

The one’s complement of 110010101 is:

a)

001101010

b)

110010101

c)

001101011

d)

110010100

89.

What will be the output of the following Python code if a=10 and b =20?

a)

10 20

b)

10 10

c)

20 10

d)

20 20

90.

Which is the correct operator for power(Xy)?

a)

a) X^y

b)

b) X**y

c)

c) X^^y

d)

d) None of the mentioned

91.

Which one of these is floor division?

a)

a) /

b)

b) //

c)

c) %

d)

d) None of the mentioned

92.

Operators with the same precedence are evaluated in which manner?

a)

a) Left to Right

b)

b) Right to Left

c)

c) Depends on associativity of operator

d)

d) None of the mentioned

93.
  1. Pick out the correct output of the following python command:


print(0 and 100)


a)

100

b)

True

c)

0

d)

False

94.

Which one of the following is not a valid operator in python?

a)

==

b)

=!

c)

**

d)

//

95.

Which of the following is not a valid operator in python?

a)

<

b)

or

c)

 is

d)

=>

96.
  1. What will be the updated value of x if  x = 9:

  x //= 3


a)

6

b)

9

c)

3

d)

None of the above

97.

   In python what is the default type of input data taken using input() function?


a)

Integer

b)

Object

c)

Decimal

d)

String

98.

Is there any limit of statements that can appear under an if block?

a)

Yes, up to 10

b)

No

c)

Yes, up to 5

d)

Can’t say

99.

What keyword would you use to add an alternative condition to an if statement?

a)

elif

b)

else if

c)

elseif

d)

None of the above

100.

Which of the following is a valid python if statement?

a)

if a >= 2 :

b)

if (a => 2)

c)

if a >= 2

d)

if (a >= 2)

101.

What will be the output of the following code?


          x = 8

               if  x > 8:

                      print(16)

                elif  x == 8:

                      print(8)

          else:

                      print(88)


a)

8

b)

16

c)

88

d)

None of the above

102.

Can we write if/else into one line in python?

a)

No

b)

Can’t say

c)

Yes

d)

None of the above

103.

1 << 2 + 3 << 4 ??

a)

16

b)

64

c)

256

d)

512

104.

x=10

y=20

x += y += 10 ??

a)

Error

b)

40 30

c)

30 40

d)

40 40

105.

1 << 2 + 3 << 4 ??

a)

16

b)

64

c)

256

d)

512

106.

x=10

y=20

x += y += 10 ??

a)

Error

b)

40 30

c)

30 40

d)

40 40

107.

a=10

b=5

a^=b

b^=b

a^=a

a,b ???

a)

error

b)

0 0

c)

10 5

d)

5, 10

108.

Pairs which have equal precedence level??

a)

// , /

b)

<< , >>

c)

< , <<

d)

+= , **=

109.

Pairs which do not have equal precedence level??

a)

~ + -

b)

& , |

c)

^ , |

d)

< , !=

110.

a>=b and b**2+a==8 or a^b<<2>27

a)

True

b)

False

c)

true

d)

Error

111.

0==False and 2<<3>>2>4

a)

True

b)

False

c)

false

d)

Error

112.

What is right shortcut for Precedence table??

a)

E U A S B C A I M L

b)

E U A S A B C A I M L

c)

M LA S B C A I E U

d)

E U A B S C A I M L

113.

Men of small knowledge are attached to ...

a)

heavenly planets

b)

resultant good birth

c)

power,

d)

devotional activity

114.

As fools are attached to the flowers of ____________ trees without knowing the results of such attractions, ____________ men are similarly attracted by such heavenly opulence and the sense enjoyment thereof.

a)

poisonous, unenlightened

b)

nectar, enlightened

c)

poisonous, enlightened

d)

nectar , unenlightened

115.

Those who are on this path are (a)   in purpose, and their aim is one. O beloved child of the Kurus, the intelligence of those who are irresolute is many-branched.

116.

Write your name ??

4 lines
117.

What are the operators that we had discussed today?

a)

Logical

b)

Membership

c)

Unary

d)

Identity

118.

By satisfaction of the _______________________, the Supreme Personality of Godhead becomes satisfied.

a)

Spiritual master

b)

krsna

c)

nation

d)

mind

119.

Which module is given as an asignment to read?

(a)