1. What is the order of execution of statements in a program called?
2. Which control structures does Python support for flow of control?
3. How does Python group statements into a single block of code?
4. What is used to implement decision-making in Python?
5. What does the break statement do in a loop?
6. What is the purpose of the continue statement?
7. What is a loop inside another loop called?
8. Which of the following is a correct example of a nested loop in Python?
9. What happens if indentation is incorrect in a Python program?
10. How can a block of code be created in Python?
11. What is the output of the following code snippet? Python Code: num1 = 5 num2 = 6 if num1 > num2: print("first number is larger") print("Bye") else: print("second number is larger") print("Bye Bye")
12. What will be the output of the following code? Python Code: for i in range(1, 6): if i == 3: continue print(i)
13. Which statement is used to skip the rest of the code inside a loop for the current iteration only?
14. What type of loop is used in the following code? Python Code: while True: print("Infinite loop")
15. Which of the following is the correct syntax for an if..else statement in Python?
16. Which of the following programs will print the sum of all positive numbers entered by the user until a negative number is entered?
17. In a nested loop, how many times will the inner loop execute if the outer loop runs 3 times and the inner loop runs 2 times each iteration?
18. How is a block of code indicated in Python?
19. What type of error will you get if the indentation is not consistent in Python?
20. What will be the output of the following code? Python Code: for i in range(5): if i == 2: continue print(i)
21. How can the flow of control be altered in a program?
22. What does the else part of an if statement represent?
23. What does the following code do? Python Code: x = 5 y = 10 if x < y: print("x is less than y") else: print("x is not less than y")
24. What is the purpose of an infinite loop?
25. Which of the following is true about the break statement in a loop?
26. What is the output of the following code? Python Code: for i in range(4): print(i) if i == 2: break
27. How does the continue statement affect a loop's execution?
28. What is the difference between a for loop and a while loop?
29. What will be the output of the following code snippet? Python Code: count = 0 while count < 5: count += 1 print(count)
30. How many times will the loop run in the following code? Python Code: for i in range(3): for j in range(2): print(i, j)
31. Which statement is used to exit a loop in Python?
32. What will be the output of the following code? Python Code: i = 0 while i < 4: i += 1 print(i) if i == 2: continue
33. What is the purpose of a nested loop?
34. Which statement correctly describes the functionality of break and continue in Python?
35. What is the output of the following code? Python Code: for i in range(3): for j in range(2): if j == 1: break print(i, j)
36. Which of the following is a correct syntax for a while loop in Python?
37. What happens when the break statement is executed inside a nested loop?
38. Which of the following is the correct syntax for a for loop in Python?
39. How can you create a block of code in Python?
40. What is the output of the following code? Python Code: count = 0 while count < 3: print(count) count += 1
41. Which of the following statements will break out of a loop?
42. What is the purpose of the continue statement in a loop?
43. What will be the output of the following code? Python Code: for i in range(3): for j in range(2): if j == 1: break print(i, j) print("Out of nested loop")
44. What is the output of the following code? Python Code: for i in range(5): if i == 3: break print(i) else: print("Completed")
45. What is the output of the following code snippet? Python Code: for i in range(2): for j in range(2): print(i, j)
46. Which of the following is true about the for loop?
47. What will be the output of the following code? Python Code: for i in range(3): if i == 1: break print(i) else: print("Loop completed")
48. How do you implement a nested loop in Python?

No comments: