Tag: Python

  • Python Questions and Answers – Recursion

    Python Questions and Answers – Recursion

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Recursion”. Q 1. Which is the most appropriate definition for recursion?A. A function that calls itselfB. A function execution instance that calls another execution instance of the same functionC. A class method that calls another class methodD. An in-built method that is automatically called Show Answer…

  • Python Multiple Choice Questions – Argument Parsing

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Argument Parsing”. Q 1. What is the type of each element in sys.argv?A. setB. listC. tupleD. string Show Answer Answer:-D. string Explanation It is a list of strings. Q 2. What is the length of sys.argv?A. number of argumentsB. number of arguments + 1C. number of…

  • Python Questions and Answers – Function – 4

    Python Questions and Answers – Function – 4

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Function – 4”. Q 1. What is a variable defined outside a function referred to as?A. A static variableB. A global variableC. A local variableD. An automatic variable Show Answer Answer:-B. A global variable Explanation The value of a variable defined outside all function definitions is…

  • Python Questions and Answers – Function – 3

    Python Questions and Answers – Function – 3

    Python Questions focuses on “Functions”. Q 1. Python supports the creation of anonymous functions at runtime, using a construct called __________A. lambdaB. piC. anonymousD. none of the mentioned Show Answer Answer:-A. lambda Explanation Python supports the creation of anonymous functions (i.e. functions that are not bound to a name) at runtime, using a construct called…

  • Python Questions and Answers – Function – 2

    Python Questions and Answers – Function – 2

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Functions”. Q 1. Which are the advantages of functions in python?A. Reducing duplication of codeB. Decomposing complex problems into simpler piecesC. Improving clarity of the codeD. All of the mentioned Show Answer Answer:-D. All of the mentioned Explanation None. Q 2. What are the two main…

  • Python Questions and Answers – Argument Parsing 2

    Python Questions and Answers – Argument Parsing 2

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Argument Parsing”. Q 1. What will be the output of the following Python code? def foo(k):k = [1]q = [0]foo(q)print(q)A. [0]B. [1]C. [1, 0]D. [0, 1] Show Answer Answer:-A. [0] Explanation A new list object is created in the function and the reference is lost. This…

  • Python Multiple Choice Questions – Function

    Python Multiple Choice Questions – Function

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Function”. Q 1. Which of the following is the use of function in python?A. you can’t also create your own functions B. Functions don’t provide better modularity for your applicationC. Functions are reusable pieces of programsD. All of the mentioned Show Answer Answer:-C. Functions are reusable…

  • Python Question and Answers – Built-in Functions – 2

    Python Question and Answers – Built-in Functions – 2

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Built-in Functions – 2”. Q 1. What will be the output of the following Python functions? chr(‘97’)chr(97)A. a Error B. ‘a’ aC. Error a D. Error Error Show Answer Answer:-C. Error a Explanation The built-in function chr() returns the alphabet corresponding to the value given as…

  • Python Questions and Answers – Global vs Local Variables – 2

    Python Questions and Answers – Global vs Local Variables – 2

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Global vs Local Variables – 2”. Q 1. Which of the following data structures is returned by the functions globals() and locals()?A. listB. setC. dictionaryD. tuple Show Answer Answer:-C. dictionary Explanation Both the functions, that is, globals() and locals() return value of the data structure dictionary.…

  • Python Questions and Answers – Global vs Local Variables – 1

    Python Questions and Answers – Global vs Local Variables – 1

    Python Multiple Choice Questions & Answers (MCQs) focuses on “Global vs Local Variables – 1”. Q 1. What will be the output of the following Python code? def f1():x=15print(x)x=12f1()A. 10B. 12C. 15D. Error Show Answer Answer:-C. 15 Explanation In the code shown above, x=15 is a local variable whereas x=12 is a global variable. Preference…

You cannot copy content of this page