Python Variables and Data Types (Multiple Choice Questions) MCQ – Python Interview objective questions| Python Quiz

11. In Python, a variable must be declared before it is assigned a value:

  1. True
  2. False

Answer : B
Explanation: Variables need not be declared or defined in advance in Python programming. To create a variable, you just assign it a value.

12. Why does the name of local variables start with an underscore discouraged?

  1. To identify the variable
  2. It confuses the interpreter
  3. It indicates a private variable of a class
  4. None of these

Answer : C
Explanation: Since there is no concept of private variables in Python language, majorly underscore is used to denote variables that cannot be accessed from outside the class.

13. Which of the following will run without errors?

  1. round(75.8)
  2. round()
  3. round(5352.898,9,5)
  4. round(6463.123,2,6)

Answer : A
Explanation: Execute help(round) in the shell to get details of the parameters that are passed into the round function.

14. Which of the following is a valid variable?

  1. var@
  2. 32var
  3. in
  4. abc_x

Answer : D
Explanation: Variable name should not be a keyword, cannot begin with a digit, and should not contain any special symbol. Hence D is the correct identifier or variable. So, Option D is correct.

15. Is Python case sensitive when dealing with identifiers?

  1. Yes
  2. No
  3. Machine dependent
  4. None of the above

Answer : A
Explanation: Case is always significant.

16. In which data type, indexing is not valid?

  1. List
  2. String
  3. Dictionary
  4. None of the above

Answer : C
Explanation: Indexing is not valid in dictionary.

17. Select the correct example of complex datatype in Python

  1. 3 + 2j
  2. -100j
  3. 5j
  4. All of the above are correct

Answer : D
Explanation: All of the above are complex data types in python

18. What is output of: 35 == 35.0

  1. False
  2. True
  3. 33
  4. None of the above

Answer : B
Explanation: comparison operator (==) evaluates true and false. And in python, we need not specify whether the number is int or float.

19. l = [ 4, 8, 9, 2.6, 5 ] is a type of which data type in python?

  1. List
  2. Tuple
  3. Set
  4. None of these

Answer : A
Explanation: List in python is created by writing values inside [].

20. How can we create an empty list in python?

  1. list=()
  2. list.null
  3. null.list
  4. list=[]

Answer : D
Explanation: List in python is created by writing values inside []. So, for creating an empty list just leave the list as [].

This Post Has 5 Comments

Leave a Reply