1. What will be the output?
x = 12
if x > 10:
print("A")
elif x > 5:
print("B")
else:
print("C")
A) A
B) B
C) C
D) Error
2. What will be the output?
for i in range(2, 8):
print(i, end=" ")
A) 2 3 4 5 6 7
B) 2 3 4 5 6 7 8
C) 1 2 3 4 5 6 7
D) 3 4 5 6 7
3. Which statement immediately exits a loop?
A) continue
B) pass
C) break
D) stop
4. What will be the output?
for i in range(4):
pass
print(i)
A) 3
B) 4
C) 0
D) Error
5. What will be the output?
x = 15
if x % 3 == 0:
print("Divisible")
A) Divisible
B) Not Divisible
C) Error
D) Nothing
6. What is the purpose of continue?
A) Ends the loop
B) Skips the current iteration
C) Restarts the program
D) Creates a new loop
7. What will be the output?
for i in range(6):
if i == 4:
break
print(i, end=" ")
A) 0 1 2 3
B) 0 1 2 3 4
C) 1 2 3 4
D) 0 1 2
8. What will be the output?
for i in range(5):
if i == 1:
continue
print(i, end=" ")
A) 0 2 3 4
B) 0 1 2 3 4
C) 1 2 3 4
D) 0 2 4
9. Which keyword acts as a null statement in Python?
A) skip
B) break
C) continue
D) pass
10. What will be the output?
x=8
if x > 10:
print("A")
elif x > 6:
print("B")
else:
print("C")
A) A
B) B
C) C
D) Error
11. How many times will the loop execute?
for i in range(1, 11, 3):
print(i)
A) 2
B) 3
C) 4
D) 5
12. What will be the output?
i=2
while i < 8:
print(i, end=" ")
i += 2
A) 2 4 6
B) 2 4 6 8
C) 4 6 8
D) Infinite Loop
13. Which operator is used for logical AND?
A) &&
B) and
C) &
D) AND
14. What will be the output?
for i in range(2):
for j in range(3):
print("*", end="")
A) ******
B) *****
C) ***
D) Error
15. Which statement is commonly used as a placeholder for future code?
A) break
B) continue
C) pass
D) skip
16. What will be the output?
x = 20
if x > 10 and x < 25:
print("True")
A) True
B) False
C) Error
D) Nothing
17. What will be the output?
for i in range(5):
if i == 2:
continue
if i == 4:
break
print(i, end=" ")
A) 0 1 3
B) 0 1 2 3
C) 1 3
D) 0 3
18. What will be the output?
x=4
if x > 5:
print("A")
elif x > 3:
print("B")
elif x > 1:
print("C")
A) A
B) B
C) C
D) Error
19. What will be the output?
for i in range(10, 4, -2):
print(i, end=" ")
A) 10 8 6
B) 10 8 6 4
C) 8 6 4
D) 10 8
20. Which loop is generally preferred when the number of iterations is known?
A) while
B) for
C) nested loop
D) infinite loop
21. What will be the output?
i=1
while i < 10:
i += 3
print(i)
A) 7
B) 10
C) 13
D) 9
22. What will be the output?
for i in range(3):
print(i)
else:
print("End")
A) 0 1 2 End
B) End
C) 0 1 End
D) Error
23. What will be the output?
for i in range(1, 8):
if i % 2 == 1:
print(i, end=" ")
A) 1 3 5 7
B) 2 4 6
C) 1 2 3 4 5 6 7
D) 3 5 7
24. What is the final value of i?
for i in range(6):
pass
A) 5
B) 6
C) 0
D) Undefined
25. What will be the output?
x=7
if x > 5:
if x < 10:
print("Python")
A) Python
B) Error
C) Nothing
D) 7
26. What will be the output?
for i in range(3):
for j in range(2):
print(i+j, end=" ")
A) 0 1 1 2 2 3
B) 1 2 3 4
C) 0 1 2 3
D) Error
27. What will be the output?
i=3
while i > 0:
print(i, end=" ")
i -= 1
else:
print("Done")
A) 3 2 1 Done
B) 3 2 1
C) Done
D) Error
28. Which function is used to generate a sequence of numbers?
A) sequence()
B) numbers()
C) range()
D) loop()
29. What will be the output?
for i in range(4):
if i == 2:
pass
print(i)
A) 0 1 3
B) 0 1 2 3
C) 2 3
D) Error
30. What will be the output?
print(8 > 5 and 2 < 1)
A) True
B) False
C) Error
D) 1
31. What will be the output?
for i in range(0, 10, 4):
print(i, end=" ")
A) 0 4 8
B) 0 4 8 12
C) 4 8
D) 0 4
32. What will be the output?
i=6
while i > 1:
i -= 2
print(i)
A) 0
B) 1
C) 2
D) 3
33. What will be the output?
for i in range(2):
for j in range(3):
if j == 2:
break
print(j, end=" ")
A) 0 1 0 1
B) 0 1 2
C) 0 0
D) 1 2
34. What will be the output?
x=2
if x > 5 or x < 3:
print("Valid")
A) Valid
B) Invalid
C) Error
D) Nothing
35. What will be the output?
for i in range(1, 7):
if i == 5:
continue
print(i, end=" ")
A) 1 2 3 4 5 6
B) 1 2 3 4 6
C) 5 6
D) 1 2 3 4 5
KYA RE PAGLA ANSWER DHUND RAHA HAI ??
GHANTA MILEGA