1 Which statement is used to test a condition and then do something if it is true? A if statement B for statement C while statement D print statement
3 Which loop is used when the number of iterations is known before the loop starts? A for loop B while loop C if-else loop D nested loop
4 Which of the following is NOT a valid list operation? A Concatenation B Repetition C Slicing D Encryption
5 What is a nested if statement? A An if statement inside another if statement B An if statement inside a loop C An if statement with multiple elif D An if statement without else
6 What does a nested condition mean? A An if statement inside another if statement B A loop inside a list C A list inside a number D A library inside a loop
7 Which tool is commonly used for debugging Python code? A print statements B compiler C interpreter D text editor
8 What is a nested condition? A An if statement inside another if statement B A loop inside a loop C A list inside a list D A function inside a function
10 What does debugging mean in programming? A Writing new code B Finding and fixing errors in code C Running the program D Deleting the code
11 Why do we use libraries in Python? A To write all code from scratch B To reuse ready-made code for common tasks C To make the program slower D To remove all errors automatically
12 Which symbol is used to access an item from a list in Python? A Parentheses ( ) B Square brackets [ ] C Curly braces { } D Angle brackets < >
13 What type of error is a syntax error? A Runtime error B Logical error C Compile-time error D Semantic error
14 What does list slicing list[1:3] return? A Elements at index 1 and 2 B Elements at index 1, 2, and 3 C Elements from index 1 to end D Elements at index 1 only
15 What is the purpose of the import statement in Python? A To include a library or module B To define a variable C To create a loop D To print output
16 What happens if the condition of a while loop always remains true? A The loop runs once and stops. B The loop never runs. C The loop runs forever (infinite loop). D The loop gives a syntax error.
17 What does my_list.append(5) do? A Removes 5 from the list B Adds 5 at the end of the list C Changes 5 to 0 D Sorts the list
18 In a nested if statement, when does the inner if condition get checked? A Always, regardless of the outer condition B Only when the outer if condition is true C Only when the outer if condition is false D Never
19 How is a list created in Python? A Using square brackets [] B Using curly brackets {} C Using round brackets () D Using angle brackets <>
20 What is a syntax error? A An error that occurs when the program is running B An error in the rules of the programming language C An error in the logic of the program D An error caused by the user
21 What does list slicing my_list[1:3] return? A Items from index 1 to 2 B Items from index 1 to 3 C Items from index 0 to 3 D The entire list
22 Which loop is best when the number of repetitions is already known? A while loop B for loop C if loop D else loop
24 What is a loop inside another loop called? A Nested loop B Hidden loop C Simple loop D Closed loop
25 What does the else block do in an if-else statement? A It runs when the if condition is true B It runs when the if condition is false C It runs always D It stops the program