0% found this document useful (0 votes)
17 views6 pages

Python MCQ Pandiyaraj

Uploaded by

iamavp1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
17 views6 pages

Python MCQ Pandiyaraj

Uploaded by

iamavp1234
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 6

Python Operators, Statements, and

Expressions - MCQ
1. 1. What will be the output of this expression?
print(3 < 2 < 1)

 A) True
 B) False
 C) Error
 D) None

Answer: B

2. 2. Which of the following returns True?


x = [1, 2]; y = [1, 2]; z = x

 A) x is y
 B) x == y
 C) x is z
 D) Both B and C

Answer: D

3. 3. What does this expression return?


True + True + False

 A) 1
 B) 2
 C) 3
 D) Error

Answer: B

4. 4. Which of the following expressions will return False?

 A) not (1 and 0)
 B) not (1 or 0)
 C) not False
 D) not None

Answer: B

5. 5. What is the output of this code?


print("5" * 3)

 A) 15
 B) 555
 C) 53
 D) Error

Answer: B

6. 6. Which operator will cause this to fail: x = 5; print(x / 0)?

 A) Division
 B) Floor division
 C) Modulo
 D) All of the above

Answer: D

7. 7. Which statement is used to skip the rest of the current iteration in a loop?

 A) skip
 B) break
 C) next
 D) continue

Answer: D

8. 8. What is the result of not 0?

 A) True
 B) False
 C) 0
 D) None

Answer: A

9. 9. What is the output of this code?


print(10 > 5 == True)

 A) True
 B) False
 C) Error
 D) None

Answer: B

10. 10. Which of the following is valid Python code?

 A) if (a := 5) > 3:
 B) if a = 5:
 C) if 5 := a:
 D) a ?= 5

Answer: A

11. 11. Which keyword is not a loop control statement?

 A) break
 B) continue
 C) exit
 D) pass

Answer: C

12. 12. Which statement does nothing when executed?

 A) continue
 B) None
 C) pass
 D) skip
Answer: C

13. 13. What is the output of this expression?


print(0 and 1 or 2 and 3)

 A) 1
 B) 3
 C) 0
 D) 2

Answer: B

14. 14. What is the result of this code?


a=5
b = a == 5
print(b)

 A) True
 B) 5
 C) False
 D) None

Answer: A

15. 15. Which of the following are assignment expressions?

 A) x += 1
 B) x = 1
 C) x := 1
 D) All of the above

Answer: D

16. 16. Which of the following is valid use of ternary operator?

 A) x = if y > 10 then 1 else 0


 B) x = 1 if y > 10 else 0
 C) x = y > 10 ? 1 : 0
 D) x = y if > 10 else 0

Answer: B

17. 17. What will be the output of bool('False')?

 A) False
 B) True
 C) Error
 D) None

Answer: B

18. 18. Which of the following returns the same result as x % y?

 A) math.remainder(x, y)
 B) divmod(x, y)[1]
 C) x - y
 D) x // y

Answer: B

19. 19. What is the output of this code?


x=5
print(x == 5.0)

 A) True
 B) False
 C) Error
 D) None

Answer: A

20. 20. Which operator can be used for checking both condition and assignment in one line
(Python 3.8+)?

 A) :=
 B) ==
 C) is
 D) ->

Answer: A

You might also like