1 Which of the following is a type of error that occurs when the code is syntactically correct but produces incorrect results? A Syntax error B Semantic error C Runtime error D None of the above
2 What does the following code do?\nimport random\nprint(random.randint(1, 10)) A Prints a random integer between 1 and 10 B Prints numbers from 1 to 10 C Prints 1 and 10 D Causes an error
3 پائتھن میں print() فنکشن کیا کرتا ہے؟ A صارف سے ان پٹ لیتا ہے B سکرین پر آؤٹ پٹ دکھاتا ہے C متغیر میں ڈیٹا محفوظ کرتا ہے D متغیر کو حذف کرتا ہے
5 Which tool is commonly used for debugging Python code? A print statements B compiler C interpreter D text editor
7 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
8 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
9 What does the following code do? my_list = [1, 2, 3] my_list.append(4) A Adds 4 at the beginning B Adds 4 at the end C Removes 4 D Replaces 4 with 1
10 Which of the following is used to install Python on a computer? A Python installer B Python compiler C Python interpreter D Python editor
11 Which statement about debugging is correct? A Debugging is done after testing finds a problem. B Debugging means writing the first version of code. C Debugging is only for hardware. D Debugging removes all comments from code.
12 What is a loop inside another loop called? A Nested loop B Hidden loop C Simple loop D Closed loop
13 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
14 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 -->
15 پائتھن پروگرام میں غلطیاں تلاش کرنے اور انہیں ٹھیک کرنے کے لیے کون سا عمل استعمال ہوتا ہے؟ A Testing B Debugging C Compiling D Coding
16 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
17 What type of error occurs when the program is syntactically correct but gives wrong results? A Syntax error B Runtime error C Logical error D Compile error
18 What is testing in Python mainly used for? A To find errors in a program B To make the program longer C To import libraries D To delete lists
19 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
20 What is the purpose of the elif statement in Python? A To check another condition if the previous conditions are false B To repeat a block of code C To define a function D To import a library
22 if-else ڈھانچے میں else بلاک کیا کرتا ہے؟ A یہ اس وقت چلتا ہے جب if کی شرط درست ہو B یہ اس وقت چلتا ہے جب if کی شرط غلط ہو C یہ کوئی اور شرط جانچتا ہے D یہ پروگرام روک دیتا ہے
23 What does the break statement do inside a loop? A Stops the loop immediately B Pauses the loop C Skips the current iteration D Restarts the loop
24 What is the purpose of the else clause in an if-else statement? A It executes when the if condition is false B It executes when the if condition is true C It is used to test another condition D It stops the program
25 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