Python Datatypes, Operators and Conditional Statements

Python Datatypes, Operators and Conditional Statements Quiz

Last Updated :
Discuss
Comments

Question 1

What is the purpose of the else clause in a Python if-else statement?

  • It is used to handle exceptions.

  • It is executed when the if condition is true.

  • It is executed when none of the preceding if or elif conditions are true.

  • It is used to terminate the program.

Question 2

Find the output of the below python program:

tup= (1, 2, 3, 4) 
tup.append( (5, 6, 7) )
print(len(tup))
  • 5

  • 6

  • 3

  • Compilation Error 

Question 3

Find the output of the below python program:

tuple1 = (1, 2, 4, 3) 
tuple2 = (1, 2, 3, 4) 
print(tuple1 < tuple2) 
  • Error 

  • True 

  • False

  • false

Question 4

Find the output of the below python code:

set1 = {1, 2, 3} 
set2 = {4, 5, 6} 
print(len(set1 + set2)) 
  • 3

  • 6

  • Error 

  • Unexpected

Question 5

What is the type casting in the below code:

a=11
print(str(a))

  • Implicit type conversion 

  • Explicit type conversion 

  • None of the above

Question 6

What is the result of the bitwise operation 10 & 4 in Python?

  • 0

  • 2

  • 10

  • 14

Question 7

Which of the following is a membership operator in Python?
  • in
  • is
  • not
  • and

Question 8

What will be the output of this code?

x = 5

x += 3

x *= 2

print(x)


  • 16

  • 13

  • 18

  • 10

Question 9

What will be the output of the expression (5 > 3) and (2 < 4)?

  • True

  • False

  • 1

  • 0

Question 10

What is the result of the expression 10 // 3 in Python?

  • 3

  • 3.33

  • 4

  • 0

Tags:

There are 14 questions to complete.

Take a part in the ongoing discussion