1) What is a control structure in programming? a) A command that stores user input b) A code block that dictates the flow of execution c) A tool for debugging syntax errors 2) Which of the following is not a main type of control structure? a) Sequence b) Selection c) Compilation 3) What does the sequence control structure do? a) Executes instructions in order, one after another b) Chooses between alternative paths c) Repeats instructions until a condition is met 4) Which operator checks for equality in Python? a) == b) = c) === 5) What is the correct syntax for a simple if statement in Python? a) if condition then statement(s) b) if (condition) {statement(s)} c) if condition: statement(s) 6) What is the purpose of an if…else statement? a) To repeat a set of statements b) To execute one block of code if a condition is true, otherwise another block c) To combine two conditions into one 7) What is a nested if statement? a) A function that loops multiple times b) A conditional that checks multiple variables in one line c) An if statement inside another if statement 8) Which of the following best describes a for loop? a) It repeats a block of code a specific number of times or for each item in a sequence b) It runs indefinitely until a break condition occurs c) It executes code only if a condition is true 9) When is a while loop used? a) When the number of iterations is known b) When the number of iterations is unknown and depends on a condition c) When you want to iterate through a list 10) What is the difference between a pre-test and post-test loop? a) Both check conditions at the same time b) A pre-test loop checks after execution; post-test before execution c) A pre-test loop checks the condition before execution; a post-test loop checks it after 11) What does the break statement do? a) Skips the current iteration b) Repeats the loop one more time c) Exits the loop immediately 12) What does the continue statement do? a) Skips the current iteration and moves to the next b) Ends the program completely c) Restarts the loop from the beginning 13) Which of the following is an example of a real-world application using control structures? a) Text formatting in Word b) Traffic light systems controlled by time of day c) Image resizing in Photoshop 14) Why are control structures essential in programming? a) They help store data efficiently b) They speed up code compilation time c) They allow logical decisions, repetition, and structure in code execution 15) Why might a while loop create an infinite loop in Python? a) The condition is always false. b) The break statement is placed at the beginning. c) The condition never becomes false because the control variable is not updated inside the loop. 16) What is the output of the following nested conditional code? a) Odd and greater than 10 b) Even and greater than 10 c) 10 or below 17) Which of the following statements about nested if statements is correct? a) The inner if executes even if the outer if condition is false. b) Nested if statements cannot contain elif clauses. c) The inner if is evaluated only if the outer if condition is true. 18) What is the key difference between a for loop and a while loop in Programming? a) A for loop always requires a counter variable. b) A for loop iterates over a sequence, while a while loop continues based on a condition. c) A while loop cannot contain nested conditions. 19) What will be the output of the following code snippet? a) 5, 4, 3, 2, 1 b) 5, 4 c) 4, 3, 2, 1 20) Which of the following best explains the role of the break and continue statements when used together in nested loops? a) Both immediately terminate all loops regardless of nesting level. b) break skips the current iteration while continue exits the outer loop. c) break terminates the current loop, while continue skips to the next iteration of the current loop.

Tabla de clasificación

Estilo visual

Opciones

Cambiar plantilla

¿Restaurar actividad almacenada automáticamente: ?