0% found this document useful (0 votes)
11 views23 pages

Mcqs

Uploaded by

demow26767
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)
11 views23 pages

Mcqs

Uploaded by

demow26767
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/ 23

1. What will be the output of the following code?

 x = 5
 if x > 2:
o if x < 10:
1. print("A")
o else:
1. print("B")
 else:
o print("C")

 A. A
 B. B
 C. C
 D. No output

1. Which of the following operators has the highest precedence in Python?


o A. +
o B. *
o C. **
o D. and
2. What will be the output of the following code?

o a = 10
o b = 20
o c = 30
o if a > b or b < c and a < c:
1. print("True")
o else:
1. print("False")

 A. True
 B. False
 C. Error
 D. No output

1. What is the associativity of the ** operator in Python?


o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
2. What will be the output of the following code?

 x = 10
 y = 20
 if x < y:
o if x == 10:
1. print("X is 10")
o else:
1. print("X is not 10")
 else:
o print("Y is less than X")

 A. X is 10
 B. X is not 10
 C. Y is less than X
 D. No output

1. Which of the following expressions will evaluate to True?


o A. not (True and False)
o B. True or False and False
o C. False and not False
o D. True and not (False or True)
2. What will be the output of the following code?

 x = 5
 y = 10
 z = 15
 if x < y < z:
o print("Chain")
 else:
o print("No Chain")

 A. Chain
 B. No Chain
 C. Error
 D. No output

1. What is the precedence of the not operator in Python?


o A. Higher than and and or
o B. Lower than and and or
o C. Same as and and or
o D. None of the above

2. What will be the output of the following code?

 a = 5
 b = 10
 if a > b:
o print("A")
 elif a == b:
o print("B")
 else:
o print("C")

 A. A
 B. B
 C. C
 D. No output

1. Which of the following has the lowest precedence in Python?


o A. +
o B. *
o C. **
o D. or
2. What will be the output of the following code?

o x = 10
o y = 5
o if x > y:
 if y < 10:
 print("Nested")
 else:
 print("Not Nested")
o else:
 print("Else")

o A. Nested
o B. Not Nested
o C. Else
o D. No output
3. What will be the output of the following code?

 a = 3
 b = 6
 c = 9
 if a < b and b < c:
 print("All True")
 else:
 print("False")

o A. All True
o B. False
o C. Error
o D. No output
4. What is the associativity of the + operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
5. What will be the output of the following code?

 x = 5
 y = 10
 if x == 5 and y == 10:
 print("Both True")
 else:
 print("One or Both False")
o A. Both True
o B. One or Both False
o C. Error
o D. No output
6. Which of the following expressions will evaluate to False?
o A. not (False or True)
o B. True and False or True
o C. False or not False
o D. True and not (False and True)
7. What will be the output of the following code?

 a = 8
 b = 4
 if a % b == 0:
 print("Divisible")
 else:
 print("Not Divisible")

o A. Divisible
o B. Not Divisible
o C. Error
o D. No output
8. What is the precedence of the and operator in Python?
o A. Higher than or
o B. Lower than or
o C. Same as or
o D. None of the above
9. What will be the output of the following code?

 x = 7
 y = 14
 if x * 2 == y:
o print("Double")
 else:
o print("Not Double")

o A. Double
o B. Not Double
o C. Error
o D. No output
10. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not
11. What will be the output of the following code? python a = 12 b = 6 if a / b == 2:
print("Half") else: print("Not Half")
o A. Half
o B. Not Half
o C. Error
o D. No output
1. What will be the output of the following code?

 x = 10
 y = 20
 z = 30
 if x < y < z and x + y > z:
o print("Condition Met")
 else:
o print("Condition Not Met")

 A. Condition Met
 B. Condition Not Met
 C. Error
 D. No output

1. Which of the following expressions will evaluate to False?


o A. not (True and (False or True))
o B. True or (False and not True)
o C. (False or True) and not False
o D. True and (False or not True)
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if (a < b and b < c) or (a > c):
print("True")
else:
print("False")

 A. True
 B. False
 C. Error
 D. No output

1. What is the associativity of the // operator in Python?


o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
2. What will be the output of the following code?

x = 5
y = 10
z = 15
if x + y > z and y - x < z:
if z % x == 0:
print("Nested True")
else:
print("Nested False")
else:
print("Outer False")

 A. Nested True
 B. Nested False
 C. Outer False
 D. No output

1. Which of the following expressions will evaluate to True?


o A. not (False or (True and False))
o B. (True and False) or not (False and True)
o C. False or (True and not False)
o D. True and (False or not (True and False))
2. What will be the output of the following code?

a = 10
b = 20
c = 30
if a < b < c and a + b == c:
print("Chain True")
else:
print("Chain False")

 A. Chain True
 B. Chain False
 C. Error
 D. No output

1. What is the precedence of the or operator in Python?


o A. Higher than and
o B. Lower than and
o C. Same as and
o D. None of the above
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if a > b:
print("A")
elif b < c:
print("B")
else:
print("C")

 A. A
 B. B
 C. C
 D. No output

1. Which of the following has the highest precedence in Python?


o A. +
o B. *
o C. **
o D. not
2. What will be the output of the following code?

 x = 10
 y = 5
 if x > y:
 if y < 10:
 if x % y == 0:
 print("Divisible")
 else:
 print("Not Divisible")
 else:
 print("Y >= 10")
 else:
 print("X <= Y")

o A. Divisible
o B. Not Divisible
o C. Y >= 10
o D. X <= Y
3. What will be the output of the following code?

 a = 3
 b = 6
 c = 9
 if a < b and b < c:
 if a + b > c:
 print("Sum Greater")
 else:
 print("Sum Not Greater")
 else:
 print("Condition False")

o A. Sum Greater
o B. Sum Not Greater
o C. Condition False
o D. No output
4. What is the associativity of the - operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
5. What will be the output of the following code?

 x = 5
 y = 10
 z = 15
 if x == 5 and y == 10:
 if z == 15:
 print("All True")
 else:
 print("Z False")
 else:
 print("X or Y False")

o A. All True
o B. Z False
o C. X or Y False
o D. No output
6. Which of the following expressions will evaluate to False?
o A. not (False or (True and False))
o B. (True and False) or not (False and True)
o C. False or (True and not False)
o D. True and (False or not (True and False))
7. What will be the output of the following code?

 a = 8
 b = 4
 if a % b == 0:
 if a // b == 2:
 print("Divisible and Half")
 else:
 print("Divisible but Not Half")
 else:
 print("Not Divisible")

o A. Divisible and Half


o B. Divisible but Not Half
o C. Not Divisible
o D. No output
8. What is the precedence of the and operator in Python?
o A. Higher than or
o B. Lower than or
o C. Same as or
o D. None of the above
9. What will be the output of the following code?

 x = 7
 y = 14
 if x * 2 == y:
 if y / x == 2:
 print("Double and Half")
 else:
 print("Double but Not Half")
 else:
 print("Not Double")

o A. Double and Half


o B. Double but Not Half
o C. Not Double
o D. No output
10. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not
11. What will be the output of the following code?

a = 12

b = 6

if a / b == 2:

if a % b == 0:

print("Half and Divisible")

else:

print("Half but Not Divisible")

else: print("Not Half")

o A. Half and Divisible


o B. Half but Not Divisible
o C. Not Half
o D. No output

I hope these questions help you practice and understand conditional statements, precedence, and
associativity better! If you need explanations for any of the answers, feel free to ask.

Sure! Here are 10 advanced and complex multiple-choice questions (MCQs) focusing on
conditional statements, precedence, and associativity in Python:

1. What will be the output of the following code?

x = 10
y = 20
z = 30
if (x < y and y < z) or (x + y == z):
if (x * y) % z == 0:
print("Condition Met")
else:
print("Condition Partially Met")
else:
print("Condition Not Met")

 A. Condition Met
 B. Condition Partially Met
 C. Condition Not Met
 D. No output
1. Which of the following expressions will evaluate to True?
o A. not (True and (False or (True and False)))
o B. True or (False and (not True or False))
o C. (False or (True and not False)) and True
o D. True and (False or (not (True and False)))
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if (a < b and b < c) or (a > c and b < c):
if (a + b) % c == 0:
print("True")
else:
print("False")
else:
print("Condition Not Met")

 A. True
 B. False
 C. Condition Not Met
 D. No output

1. What is the associativity of the ** operator in Python?


o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
2. What will be the output of the following code?

x = 5
y = 10
z = 15
if (x + y > z and y - x < z) or (z % x == 0):
if (x * y) % z == 0:
print("Nested True")
else:
print("Nested False")
else:
print("Outer False")

 A. Nested True
 B. Nested False
 C. Outer False
 D. No output

1. Which of the following expressions will evaluate to False?


o A. not (False or (True and (False or True)))
o B. (True and (False or not True)) or False
o C. False or (True and (not False or True))
o D. True and (False or (not (True and False)))
2. What will be the output of the following code?

a = 10
b = 20
c = 30
if (a < b < c and a + b == c) or (a * b > c):
if (a + c) % b == 0:
print("Chain True")
else:
print("Chain False")
else:
print("Condition Not Met")

 A. Chain True
 B. Chain False
 C. Condition Not Met
 D. No output

1. What is the precedence of the not operator in Python?


o A. Higher than and and or
o B. Lower than and and or
o C. Same as and and or
o D. None of the above
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if (a > b and b < c) or (a == b and b == c):
if (a + b + c) % 2 == 0:
print("Even Sum")
else:
print("Odd Sum")
else:
print("Condition Not Met")

 A. Even Sum
 B. Odd Sum
 C. Condition Not Met
 D. No output

1. Which of the following has the highest precedence in Python?


o A. +
o B. *
o C. **
o D. not

1. What will be the output of the following code?

x = 10
y = 20
z = 30
if (x < y and y < z) or (x + y == z):
if (x * y) % z == 0:
print("Condition Met")
else:
print("Condition Partially Met")
else:
print("Condition Not Met")

 A. Condition Met
 B. Condition Partially Met
 C. Condition Not Met
 D. No output

1. Which of the following expressions will evaluate to True?


o A. not (True and (False or (True and False)))
o B. True or (False and (not True or False))
o C. (False or (True and not False)) and True
o D. True and (False or (not (True and False)))
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if (a < b and b < c) or (a > c and b < c):
if (a + b) % c == 0:
print("True")
else:
print("False")
else:
print("Condition Not Met")

 A. True
 B. False
 C. Condition Not Met
 D. No output

1. What is the associativity of the ** operator in Python?


o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
2. What will be the output of the following code?

x = 5
y = 10
z = 15
if (x + y > z and y - x < z) or (z % x == 0):
if (x * y) % z == 0:
print("Nested True")
else:
print("Nested False")
else:
print("Outer False")

 A. Nested True
 B. Nested False
 C. Outer False
 D. No output

1. Which of the following expressions will evaluate to False?


o A. not (False or (True and (False or True)))
o B. (True and (False or not True)) or False
o C. False or (True and (not False or True))
o D. True and (False or (not (True and False)))
2. What will be the output of the following code?

a = 10
b = 20
c = 30
if (a < b < c and a + b == c) or (a * b > c):
if (a + c) % b == 0:
print("Chain True")
else:
print("Chain False")
else:
print("Condition Not Met")

 A. Chain True
 B. Chain False
 C. Condition Not Met
 D. No output

1. What is the precedence of the not operator in Python?


o A. Higher than and and or
o B. Lower than and and or
o C. Same as and and or
o D. None of the above
2. What will be the output of the following code?

a = 5
b = 10
c = 15
if (a > b and b < c) or (a == b and b == c):
if (a + b + c) % 2 == 0:
print("Even Sum")
else:
print("Odd Sum")
else:
print("Condition Not Met")

 A. Even Sum
 B. Odd Sum
 C. Condition Not Met
 D. No output

1. Which of the following has the highest precedence in Python?


o A. +
o B. *
o C. **
o D. not
2. What will be the output of the following code?

 x = 10
 y = 5
 if x > y:
 if y < 10:
 if x % y == 0:
 print("Divisible")
 else:
 print("Not Divisible")
 else:
 print("Y >= 10")
 else:
 print("X <= Y")

o A. Divisible
o B. Not Divisible
o C. Y >= 10
o D. X <= Y
3. What will be the output of the following code?

 a = 3
 b = 6
 c = 9
 if a < b and b < c:
 if a + b > c:
 print("Sum Greater")
 else:
 print("Sum Not Greater")
 else:
 print("Condition False")

o A. Sum Greater
o B. Sum Not Greater
o C. Condition False
o D. No output
4. What is the associativity of the - operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
5. What will be the output of the following code?
 x = 5
 y = 10
 z = 15
 if x == 5 and y == 10:
 if z == 15:
 print("All True")
 else:
 print("Z False")
 else:
 print("X or Y False")

o A. All True
o B. Z False
o C. X or Y False
o D. No output
6. Which of the following expressions will evaluate to False?
o A. not (False or (True and False))
o B. (True and False) or not (False and True)
o C. False or (True and not False)
o D. True and (False or not (True and False))
7. What will be the output of the following code?

 a = 8
 b = 4
 if a % b == 0:
 if a // b == 2:
 print("Divisible and Half")
 else:
 print("Divisible but Not Half")
 else:
 print("Not Divisible")

o A. Divisible and Half


o B. Divisible but Not Half
o C. Not Divisible
o D. No output
8. What is the precedence of the and operator in Python?
o A. Higher than or
o B. Lower than or
o C. Same as or
o D. None of the above
9. What will be the output of the following code?

 x = 7
 y = 14
 if x * 2 == y:
 if y / x == 2:
 print("Double and Half")
 else:
 print("Double but Not Half")
 else:
 print("Not Double")

o A. Double and Half


o B. Double but Not Half
o C. Not Double
o D. No output
10. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not
11. What will be the output of the following code?

 a = 12
 b = 6
 if a / b == 2:
 if a % b == 0:
 print("Half and Divisible")
 else:
 print("Half but Not Divisible")
 else:
 print("Not Half")

o A. Half and Divisible


o B. Half but Not Divisible
o C. Not Half
o D. No output
12. What will be the output of the following code?

 x = 10
 y = 20
 z = 30
 if (x < y and y < z) or (x + y == z):
 if (x * y) % z == 0:
 print("Condition Met")
 else:
 print("Condition Partially Met")
 else:
 print("Condition Not Met")

o A. Condition Met
o B. Condition Partially Met
o C. Condition Not Met
o D. No output
13. Which of the following expressions will evaluate to True?
o A. not (True and (False or (True and False)))
o B. True or (False and (not True or False))
o C. (False or (True and not False)) and True
o D. `True

Sure, let's continue with the remaining questions:


21. What will be the output of the following code?

 x = 10
 y = 20
 z = 30
 if (x < y and y < z) or (x + y == z):
 if (x * y) % z == 0:
 print("Condition Met")
 else:
 print("Condition Partially Met")
 else:
 print("Condition Not Met")

o A. Condition Met
o B. Condition Partially Met
o C. Condition Not Met
o D. No output
22. Which of the following expressions will evaluate to True?
o A. not (True and (False or (True and False)))
o B. True or (False and (not True or False))
o C. (False or (True and not False)) and True
o D. True and (False or (not (True and False)))
23. What will be the output of the following code?

 a = 5
 b = 10
 c = 15
 if (a < b and b < c) or (a > c and b < c):
 if (a + b) % c == 0:
 print("True")
 else:
 print("False")
 else:
 print("Condition Not Met")

o A. True
o B. False
o C. Condition Not Met
o D. No output
24. What is the associativity of the ** operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
25. What will be the output of the following code?

 x = 5
 y = 10
 z = 15
 if (x + y > z and y - x < z) or (z % x == 0):
 if (x * y) % z == 0:
 print("Nested True")
 else:
 print("Nested False")
 else:
 print("Outer False")

o A. Nested True
o B. Nested False
o C. Outer False
o D. No output
26. Which of the following expressions will evaluate to False?
o A. not (False or (True and (False or True)))
o B. (True and (False or not True)) or False
o C. False or (True and (not False or True))
o D. True and (False or (not (True and False)))
27. What will be the output of the following code?

 a = 10
 b = 20
 c = 30
 if (a < b < c and a + b == c) or (a * b > c):
 if (a + c) % b == 0:
 print("Chain True")
 else:
 print("Chain False")
 else:
 print("Condition Not Met")

o A. Chain True
o B. Chain False
o C. Condition Not Met
o D. No output
28. What is the precedence of the not operator in Python?
o A. Higher than and and or
o B. Lower than and and or
o C. Same as and and or
o D. None of the above
29. What will be the output of the following code?

 a = 5
 b = 10
 c = 15
 if (a > b and b < c) or (a == b and b == c):
 if (a + b + c) % 2 == 0:
 print("Even Sum")
 else:
 print("Odd Sum")
 else:
 print("Condition Not Met")

o A. Even Sum
o B. Odd Sum
o C. Condition Not Met
o D. No output
30. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not
31. What will be the output of the following code?

 x = 10
 y = 5
 if x > y:
 if y < 10:
 if x % y == 0:
 print("Divisible")
 else:
 print("Not Divisible")
 else:
 print("Y >= 10")
 else:
 print("X <= Y")

o A. Divisible
o B. Not Divisible
o C. Y >= 10
o D. X <= Y
32. What will be the output of the following code?

 a = 3
 b = 6
 c = 9
 if a < b and b < c:
 if a + b > c:
 print("Sum Greater")
 else:
 print("Sum Not Greater")
 else:
 print("Condition False")

o A. Sum Greater
o B. Sum Not Greater
o C. Condition False
o D. No output
33. What is the associativity of the - operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
34. What will be the output of the following code?
 x = 5
 y = 10
 z = 15
 if x == 5 and y == 10:
 if z == 15:
 print("All True")
 else:
 print("Z False")
 else:
 print("X or Y False")

o A. All True
o B. Z False
o C. X or Y False
o D. No output
35. Which of the following expressions will evaluate to False?
o A. not (False or (True and False))
o B. (True and False) or not (False and True)
o C. False or (True and not False)
o D. True and (False or not (True and False))
36. What will be the output of the following code?

 a = 8
 b = 4
 if a % b == 0:
 if a // b == 2:
 print("Divisible and Half")
 else:
 print("Divisible but Not Half")
 else:
 print("Not Divisible")

o A. Divisible and Half


o B. Divisible but Not Half
o C. Not Divisible
o D. No output
37. What is the precedence of the and operator in Python?
o A. Higher than or
o B. Lower than or
o C. Same as or
o D. None of the above
38. What will be the output of the following code?

 x = 7
 y = 14
 if x * 2 == y:
 if y / x == 2:
 print("Double and Half")
 else:
 print("Double but Not Half")
 else:
 print("Not Double")

o A. Double and Half


o B. Double but Not Half
o C. Not Double
o D. No output
39. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not
40. What will be the output of the following code?

 a = 12
 b = 6
 if a / b == 2:
 if a % b == 0:
 print("Half and Divisible")
 else:
 print("Half but Not Divisible")
 else:
 print("Not Half")

o A. Half and Divisible


o B. Half but Not Divisible
o C. Not Half
o D. No output
41. What will be the output of the following code?

 x = 10
 y = 20
 z = 30
 if (x < y and y < z) or (x + y == z):
 if (x * y) % z == 0:
 print("Condition Met")
 else:
 print("Condition Partially Met")
 else:
 print("Condition Not Met")

o A. Condition Met
o B. Condition Partially Met
o C. Condition Not Met
o D. No output
42. Which of the following expressions will evaluate to True?
o A. not (True and (False or (True and False)))
o B. True or (False and (not True or False))
o C. (False or (True and not False)) and True
o D. True and (False or (not (True and False)))
43. What will be the output
43. What will be the output of the following code?

 a = 5
 b = 10
 c = 15
 if (a < b and b < c) or (a > c and b < c):
 if (a + b) % c == 0:
 print("True")
 else:
 print("False")
 else:
 print("Condition Not Met")

o A. True
o B. False
o C. Condition Not Met
o D. No output
44. What is the associativity of the ** operator in Python?
o A. Left to right
o B. Right to left
o C. None
o D. Depends on the context
45. What will be the output of the following code?

 x = 5
 y = 10
 z = 15
 if (x + y > z and y - x < z) or (z % x == 0):
 if (x * y) % z == 0:
 print("Nested True")
 else:
 print("Nested False")
 else:
 print("Outer False")

o A. Nested True
o B. Nested False
o C. Outer False
o D. No output
46. Which of the following expressions will evaluate to False?
o A. not (False or (True and (False or True)))
o B. (True and (False or not True)) or False
o C. False or (True and (not False or True))
o D. True and (False or (not (True and False)))
47. What will be the output of the following code?

 a = 10
 b = 20
 c = 30
 if (a < b < c and a + b == c) or (a * b > c):
 if (a + c) % b == 0:
 print("Chain True")
 else:
 print("Chain False")
 else:
 print("Condition Not Met")

o A. Chain True
o B. Chain False
o C. Condition Not Met
o D. No output
48. What is the precedence of the not operator in Python?
o A. Higher than and and or
o B. Lower than and and or
o C. Same as and and or
o D. None of the above
49. What will be the output of the following code?

 a = 5
 b = 10
 c = 15
 if (a > b and b < c) or (a == b and b == c):
 if (a + b + c) % 2 == 0:
 print("Even Sum")
 else:
 print("Odd Sum")
 else:
 print("Condition Not Met")

o A. Even Sum
o B. Odd Sum
o C. Condition Not Met
o D. No output
50. Which of the following has the highest precedence in Python?
o A. +
o B. *
o C. **
o D. not

You might also like