Basics of Python – Multiple Choice Questions (MCQs)
-
-
26. Which function is often used with 'for' loops to iterate over a sequence of numbers?
-
27. What is the output of the following code? `for i in range(3): print(i)`?
-
28. Which keyword is used to start a 'while' loop in Python?
-
29. What is the output of the following code? `x = 0; while x < 3: print(x); x += 1`?
-
30. Which keyword is used to exit a loop prematurely in Python?
-
31. Which keyword is used to skip the current iteration of a loop and move to the next?
-
32. What is the output of the following code? `for i in range(5): if i == 3: break; print(i)`?
-
33. What is the output of the following code? `for i in range(5): if i == 3: continue; print(i)`?
-
34. What is a list in Python?
-
35. How do you access the first element of a list called 'my_list'?
-
36. What is a tuple in Python?