GATE Exam » GATE MCQs » Python MCQs

Python MCQs

Python is a programming language, basically a very high-level and a general-purpose language. The design is such that it lays emphasis on code readability with the use of significant indentation. The language used in python helps construct an object-oriented approach with the aim to help the programmers write clear and logical codes for small and large-scale products.

The idea of Python was conceived by Guido van Rossum in the later 1980s at the Centrum Wiskunde & Informatica (CWI), Netherlands. It was seen to be a successor to the ABC programming language. It was inspired by SETL, and was capable of exceptional handling and interfacing with the Amoeba operating system.

Multiple Choice Questions (MCQs):

  1. When was Python released?
  1. 16 October, 2001
  2. 16 October 2000
  3. 17 October 2000
  4. 17 October 2001

Answer. b. 16 October 2000. The idea of Python was conceived in the later 1980s, but it was released on a. 16 October 2000.

  1. When was Python 3.0 released?
  1. 3 December 2008
  2. 4 December 2008
  3. 5 December 2008
  4. 3 December 2010

Answer. a. The new version of Python 3.0 was released on December 3, 2008.

  1. Who founded Python?
  1. Alexander G. Bell
  2. Vincent van Gogh 
  3. Leonardo da Vinci
  4. Guido van Rossum

Answer. d. The idea of Python was conceived by Guido van Rossum in the later 1980s.

  1. What is Python?
  1. A programming language
  2. Computer language
  3. Binary language
  4. None of the above

Answer. a. Python is a programming language, basically a very high-level and a general-purpose language.

  1. What does the name Python signify?
  1. It is a snake
  2. It is very difficult to use
  3. Named after the British comedy group Monty Python
  4. All of the above

Answer. c. It is named after a British comedy group called the Monty Python to signify that it is very easy to use. 

  1. What are the people who specialize in Python called?
  1. Pythonic
  2. Unpythonic
  3. Monty Python
  4. Pythoniasts

Answer. d. the people who specialize, or are great admirers of this programming language are called as Pythoniasts. They are extremely knowledgeable people.

  1. What is the type of programming language supported by Python?
  1. Object-oriented
  2. Functional programming
  3. Structured programming
  4. All of the above

Answer. d. Python is an interpreted programming language, supporting object-oriented, structured, and functional programming.

  1. When Python is dealing with identifiers, is it case sensitive?
  1. Yes
  2. No
  3. Machine dependent
  4. Can’t say

Answer. a. It is case sensitive.

  1. What is the extension of the Python file?
  1. .pl
  2. .py
  3. .python
  4. .p

Answer. b. The correct extension of python is .py and can be written in any text editor. We need to use the extension .py to save these files.

  1. All the keywords in Python are in_
  1. Lower case
  2. Upper case
  3. Capitalized
  4. None of the above

Answer. d. Only True, False and None are capitalized and all the others in lower case.

  1. What does pip mean in Python?
  1. Unlimited length
  2. All private members must have leading and trailing underscores
  3. Preferred Installer Program
  4. None of the above

Answer. c. Variable names can be of any length. 

  1. The built-in function in Python is:
  1. Print ()
  2. Seed ()
  3. Sqrt ()
  4. Factorial ()

Answer. a. The function seed is a function which is present in the random module. The functions sqrt and factorial are a part of the math module. The print function is a built-in function which prints a value directly to the system output.

  1. Which of the following definitions is the one for packages in Python?
  1. A set of main modules
  2. A folder of python modules
  3. Set of programs making use of python modules
  4. Number of files containing python definitions and statements

Answer. b. A folder of python modules is called as package of modules

  1. What is the order in which namespaces in Python looks for an identifier?
  1. First, the python searches for the built-in namespace, then the global namespace and then the local namespace
  2. Python first searches for the built-in namespace, then local and finally the global namespace
  3. Python first searches for local namespace, then global namespace and finally the built-in namespace
  4. Python searches for the global namespace, followed by the local namespace and finally the built-in namespace.

Answer. C. Python first searches for the local namespace, followed by the global and finally the built-in namespace.

  1. Which of the following is not a keyword used in Python language?
  1. Pass
  2. Eval
  3. Assert
  4. Nonlocal

Answer. b. Eval is used as a variable in Python.

  1. Which of the following is the use of function in python?
  1. Functions do not provide better modularity for applications
  2. One can’t create our own functions
  3. Functions are reusable pieces of programs
  4. All of the above

Answer. c. Functions are reusable pieces of programs, which allow us to give a name to a particular block of statements, allowing us to run the block using the specified name anywhere in our program and any number of times.  

  1. Which of the following is a feature of Python DocString?
  1. All functions should have a docstring in python
  2. DocStrings can be accessed by the _doc_ attribute on objects
  3. This feature provides a very convenient way of associating documentation with python modules, functions, classes and methods
  4. All of the above

Answer. d. Python has a nifty feature, which is referred to as the documentation strings, usually referred to by its abbreviated name of docstrings. They are important tools and one must use them as they help document the program better along with making it easier to understand.

  1. Which of the following is the use of the function id() in python?
  1. Every object does not have a unique id in Python
  2. The id function in python returns the identity of the object
  3. None
  4. All

Answer. b. Every function in Python has a unique id. The id() function helps return the id of the object

  1. What is the function of pickling in python?
  1. Conversion of a python object
  2. Conversion of database into list
  3. Conversion of byte stream into python object hierarchy
  4. Conversion of list into database

Answer. a. The process of pickling refers to sterilizing a Python object, which means converting a byte stream into python object hierarchy. The process which is the opposite of pickling is called unpickling.

  1. What is Python code-compiled or interpreted?
  1. The code is both compiled and interpreted
  2. Neither compiled nor interpreted
  3. Only compiled
  4. Only interpreted

Answer. b. There are a lot of languages which have been implemented using both compilers and interpreters, including C, Pascal, as well as python.