1 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
2 What does the else block do in an if-else structure? A It runs when the if condition is true B It runs when the if condition is false C It stops the program D It defines a loop
3 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
5 How many times does the inner loop run for each single run of the outer loop in a nested loop? A Zero times B One time C As many times as its own condition allows D Only when the outer loop ends
6 Which of the following is NOT a valid list operation? A Concatenation B Repetition C Slicing D Encryption
7 What does a nested loop mean? A A loop inside another loop B Two loops that run one after the other C A loop that never ends D A loop without a condition
8 Which of the following is true about Python variables? A They must be declared with a data type. B They can change their data type during execution. C They cannot store strings. D They must start with a digit.
9 پائتھن میں کس آپریٹر کی precedence سب سے زیادہ ہے؟ A جمع (+) B ضرب (*) C ایکسپونینٹیشن (**) D اسائنمنٹ (=)
10 What does the elif statement do in Python? A Checks another condition if previous if is false B Stops the program C Creates a new list D Imports a library
11 What is testing in Python? A Writing code without errors B Running a program to check its output C Compiling the program D Encrypting the program
12 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
13 Which loop is best when you do not know in advance how many times to repeat a block of code? A for loop B while loop C if loop D def loop
14 What does the append() method do to a list? A Adds an item at the end of the list B Removes the last item from the list C Sorts the list in ascending order D Reverses the order of items in the list
16 What is a loop inside another loop called? A Nested loop B Hidden loop C Simple loop D Closed loop
17 What is the correct way to write a multi-line comment in Python? A Use # before each line B Use /* */ C Use ''' ''' or """ """ D Use //
19 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
20 How do you use a library in Python? A By writing import library_name B By writing library_name.import C By writing use library_name D By writing include library_name
21 What is the purpose of an IDE in Python programming? A To write and run programs in one place B To increase the speed of the computer C To create web pages only D To print documents
22 What is the purpose of debugging in programming? A To write code faster B To find and fix errors C To make the program run slower D To add more features
23 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
24 What is the main purpose of testing a program? A To make the program run faster B To find and fix errors C To add more features D To change the programming language
25 if-else ڈھانچے میں else بلاک کیا کرتا ہے؟ A یہ اس وقت چلتا ہے جب if کی شرط درست ہو B یہ اس وقت چلتا ہے جب if کی شرط غلط ہو C یہ کوئی اور شرط جانچتا ہے D یہ پروگرام روک دیتا ہے