Conditional Statements, Iterative Statements (Loops)

1 / 50

What is the output of: for i in range(1): print(i)?

2 / 50

How do you loop through a list and get only even-indexed elements?

3 / 50

What does ‘while False:’ with an ‘else’ block do?

4 / 50

What is the output of: x = 1; x = x + 1 if x > 0 else 0; print(x)

5 / 50

Which of these is used to define the block of code inside an ‘if’ statement?

6 / 50

What will happen? x = 10; while x > 5: print(x)

7 / 50

What does ‘break’ do in an infinite ‘while True’ loop?

8 / 50

Which of the following is correct for iterating through a list ‘fruits’ backward?

9 / 50

What is the result of ‘if True and False or True:’?

10 / 50

How many times will ‘Hello’ be printed? for i in range(2): for j in range(2): print(‘Hello’)

11 / 50

Which of these is the ‘not’ operator in Python conditionals?

12 / 50

What is the result of ‘for x in range(-3):’?

13 / 50

What is the output of ‘if “” : print(“True”) else: print(“False”)’?

14 / 50

Which of the following creates a SyntaxError?

15 / 50

In a ‘for’ loop, what is ‘i’ in ‘for i in range(5):’?

16 / 50

What is the output of: for i in range(1, 10, 3): print(i, end=’ ‘)?

17 / 50

What is the result of ‘while None:’?

18 / 50

Which of these is used for ‘short-circuit’ evaluation in conditionals?

19 / 50

How do you check if a list ‘L’ is empty using ‘if’?

20 / 50

Which function allows you to get the index and value at the same time in a for loop?

21 / 50

What will ‘if [0]: print(‘A’)’ do?

22 / 50

What is the correct way to write an infinite loop using ‘while’?

23 / 50

What is the value of ‘i’ after this loop: for i in range(3): pass?

24 / 50

Which of these represents a ‘do-while’ loop in Python?

25 / 50

What is the output of: for i in range(1, 1): print(i)

26 / 50

Which keyword is used to handle situations where no condition in an ‘if-elif’ chain is met?

27 / 50

How do you loop through a dictionary to get both keys and values?

28 / 50

What is the output of: x = 5; print(‘Yes’) if x > 2 else print(‘No’)

29 / 50

What happens when you use ‘break’ in a nested loop?

30 / 50

Which of these is a valid Python ternary operator equivalent?

31 / 50

What is the output of: for x in ‘Hi’: print(x)?

32 / 50

How do you check if a value ‘x’ is between 1 and 10 (inclusive)?

33 / 50

In Python, which character is used to indicate the end of an ‘if’ or ‘for’ header?

34 / 50

What does range(5, 0, -1) produce?

35 / 50

What will happen if the condition in a while loop is False from the start?

36 / 50

Which of the following is used to check multiple conditions in one ‘if’ statement?

37 / 50

What is the result of range(1, 10, 2)?

38 / 50

In a nested loop, which loop completes its iterations first?

39 / 50

Can an ‘else’ block be used with a ‘for’ loop?

40 / 50

What is the output of: for i in range(2, 4): print(i)?

41 / 50

What is the purpose of the ‘pass’ statement in a loop?

42 / 50

How do you write a ‘for’ loop that repeats 10 times?

43 / 50

Which loop condition would run forever?

44 / 50

What will range(5) generate?

45 / 50

Which keyword is used to skip the current iteration of a loop and move to the next one?

46 / 50

Which keyword is used to exit a loop prematurely?

47 / 50

What is the result of ‘if 0:’ in Python?

48 / 50

Which loop is used when you want to iterate over a sequence (like a list or string)?

49 / 50

What is the correct syntax for an ‘else if’ condition in Python?

50 / 50

Which keyword is used to start a conditional statement in Python?

Your score is

The average score is 0%

Scroll to Top