MCQOPTIONS
Saved Bookmarks
This section includes 20 Mcqs, each offering curated multiple-choice questions to sharpen your Python knowledge and support exam preparation. Choose a topic below to get started.
| 1. |
What is the output of the codes shown below? |
| A. | False, False |
| B. | False, True |
| C. | True, True |
| D. | True, False |
| Answer» E. | |
| 2. |
What is the output of the piece of code given below? |
| A. | False |
| B. | True |
| C. | 1 |
| D. | An exception is thrown |
| Answer» B. True | |
| 3. |
Fill in the blanks:In ____________________ copy, the modification done on one list affects the other list.In ____________________ copy, the modification done on one list does not affect the other list. |
| A. | shallow, deep |
| B. | memberwise, shallow |
| C. | deep, shallow |
| D. | deep, memberwise |
| Answer» B. memberwise, shallow | |
| 4. |
Where are the arguments received from the command line stored? |
| A. | sys.argv |
| B. | os.argv |
| C. | argv |
| D. | none of the mentioned |
| Answer» B. os.argv | |
| 5. |
______________ returns a dictionary of the module namespace.________________ returns a dictionary of the current namespace |
| A. | locals()globals() |
| B. | locals()locals() |
| C. | globals()locals() |
| D. | globals()globals() |
| Answer» E. | |
| 6. |
Which of these is false about recursion? |
| A. | Recursive function can be replaced by a non-recursive function |
| B. | Recursive functions usually take more memory space than non-recursive function |
| C. | Recursive functions run faster than non-recursive function |
| D. | Recursion makes programs easier to understand |
| Answer» D. Recursion makes programs easier to understand | |
| 7. |
What is the output of this code? |
| A. | Error |
| B. | 4 |
| C. | Junk value |
| D. | 1 |
| Answer» E. | |
| 8. |
The nested list undergoes shallow copy even when the list as a whole undergoes deep copy. State whether this statement is true or false. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» B. False | |
| 9. |
Fill in the line of code for calculating the factorial of a number. |
| A. | num*fact(num-1) |
| B. | (num-1)*(num-2) |
| C. | num*(num-1) |
| D. | fact(num)*fact(num-1) |
| Answer» B. (num-1)*(num-2) | |
| 10. |
In _______________ copy, the base address of the objects are copied.In _______________ copy, the base address of the objects are not copied. |
| A. | deep. shallow |
| B. | memberwise, shallow |
| C. | shallow, deep |
| D. | deep, memberwise |
| Answer» D. deep, memberwise | |
| 11. |
Which type of copy is shown in this code? |
| A. | Shallow copy |
| B. | Deep copy |
| C. | memberwise |
| D. | All of the mentioned |
| Answer» B. Deep copy | |
| 12. |
The output of the code shown below and state the type of copy that is depicted: |
| A. | [2, 4, 6, 8], shallow copy |
| B. | [2, 4, 6, 8], deep copy |
| C. | [1, 2, 3], shallow copy |
| D. | [1, 2, 3], deep copy |
| Answer» D. [1, 2, 3], deep copy | |
| 13. |
What happens if the base condition isn’t defined in recursive programs? |
| A. | Program gets into an infinite loop |
| B. | Program runs once |
| C. | Program runs n number of times where n is the argument given to the function |
| D. | An exception is thrown |
| Answer» B. Program runs once | |
| 14. |
Recursion and iteration are the same programming approach. True or False? |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |
| 15. |
Which of the following statements is false about recursion? |
| A. | Every recursive function must have a base case |
| B. | Infinite recursion can occur if the base case isn’t properly mentioned |
| C. | A recursive function makes the code easier to understand |
| D. | Every recursive function must have a return value |
| Answer» E. | |
| 16. |
Observe the following piece of code? |
| A. | Both a() and b() aren’t tail recursive |
| B. | Both a() and b() are tail recursive |
| C. | b() is tail recursive but a() isn’t |
| D. | a() is tail recursive but b() isn’t |
| Answer» D. a() is tail recursive but b() isn’t | |
| 17. |
Which is the most appropriate definition for recursion? |
| A. | A function that calls itself |
| B. | A function execution instance that calls another execution instance of the same function |
| C. | A class method that calls another class method |
| D. | An in-built method that is automatically called |
| Answer» C. A class method that calls another class method | |
| 18. |
On assigning a value to a variable inside a function, it automatically becomes a global variable. State whether true or false. |
| A. | True |
| B. | False |
| C. | May be |
| D. | Can't say |
| Answer» C. May be | |
| 19. |
Read the code shown below carefully and point out the global variables: |
| A. | x |
| B. | y and z |
| C. | x, y and z |
| D. | Neither x, nor y, nor z |
| Answer» D. Neither x, nor y, nor z | |
| 20. |
The output of code shown below is: |
| A. | Error |
| B. | 7 |
| C. | 8 |
| D. | 15 |
| Answer» C. 8 | |