1 How do you write a string in Python? A Enclosed in single or double quotes B Enclosed in square brackets C Enclosed in curly braces D Without any quotes
3 What is the purpose of testing in Python? A To make the code run faster B To find errors in the code C To add comments to the code D To change the code style
4 In an if-elif-else chain, how many elif blocks can be used? A Only one B Exactly two C As many as needed D None
5 In Python, what does the break statement do inside a loop? A Skips the current iteration and moves to the next one B Exits the loop immediately C Pauses the loop for a few seconds D Restarts the loop from the beginning
6 Which loop is best when the number of repetitions is already known? A while loop B for loop C if loop D else loop
7 پائتھن پروگرام میں غلطیاں تلاش کرنے اور انہیں ٹھیک کرنے کے لیے کون سا عمل استعمال ہوتا ہے؟ A Testing B Debugging C Compiling D Coding
8 What will the following do? x = 5; if x > 3: print('Big') A Print Big B Print nothing C Show an error D Print x
9 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
10 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.
11 What does the else block do in a for loop when it is used with a loop? A It runs if the loop finishes without break B It runs when the loop breaks C It is not allowed in Python D It stops the loop
14 What is testing in programming? A Checking if the program works correctly B Writing the program C Deleting the program D Installing Python
15 Which of the following is the correct way to start a Python program? A Start with main() B Write code directly C Use #include D Use public static void main
16 Which of the following is used to define a block of code in Python? A Parentheses () B Curly braces {} C Indentation D Square brackets []
17 append() میتھڈ فہرست کے ساتھ کیا کرتا ہے؟ A Adds an item at the end B Adds an item at the beginning C Removes the last item D Sorts the list
18 What is the purpose of the continue statement in a loop? A To skip the rest of the current iteration and move to the next B To stop the loop immediately C To restart the loop from the beginning D To pause the loop
19 Which of these is a valid Python comment? A // this is a comment B # this is a comment C /* this is a comment */ D <!-- this is a comment -->
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 Which statement about nested loops is true? A A nested loop is a loop inside another loop. B A nested loop can only be a for loop. C A nested loop cannot be used with lists. D A nested loop runs only once.
22 What is a common cause of an infinite while loop? A The loop condition is always false B The loop condition is always true C The loop body is empty D The loop uses a for statement
23 Which of the following is NOT a valid list operation? A Concatenation B Repetition C Slicing D Encryption
24 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
25 In Python, variables are created when a value is assigned to them. This means Python is a: A Strongly typed language only B Dynamically typed language C Compiled language D Markup language