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

The following quiz provides Multiple Choice Questions (MCQs) related to Python Variables and Python Data Types. This Python Quiz is also Interview (campus interview, walk-in interview, company interview), Placement or recruitment, entrance examinations, and competitive examinations oriented. You can practice these below questions to improve your python skills. You can click on the View Answer button to check the answer if you needed. Let’s solve this Python Variables and Data Types (Multiple Choice Questions) MCQ – Python Interview objective questions| Python Quiz

01. Which of the following statements assigns the value 25 to the variable x in Python:

  1. x ← 25
  2. x = 25
  3. x := 25
  4. int x = 25
  5. x << 25

Answer : B

02. In Python, a variable may be assigned a value of one type, and then later assigned a value of a different type:

  1. False
  2. True

Answer : B
Explanation: Variables are not statically typed in Python, as they are in some other programming languages.

03. Which one of the following is the correct way of declaring and initializing a variable, x with the value 7?

  1. int x
    x=7
  2. int x=7
  3. x=7
  4. declare x=7

Answer : C
Explanation: The correct way of declaring and initializing a variable, x with the value 7 is x=7.

04. What will be the output of statement 2**2**2**2

  1. 16
  2. 256
  3. 32768
  4. 65536

Answer : D
Explanation: The statement is equivalent to 2^16. So, Option D is correct.

05. Which of the following statement is False?

  1. Variable names can be arbitrarily long.
  2. They can contain both letters and numbers.
  3. Variable name can begin with underscore.
  4. Variable name can begin with number.

Answer : D
Explanation: Variable name can not begin with the number, it can only begin with a letter or underscore.

06. What is the output of the following code: print 9//2

  1. 4
  2. 4.5
  3. 4.0
  4. Error

Answer : A
Explanation: Floor Division operator “//” – The division of operands where the result is the quotient in which the digits after the decimal point are removed. So in this case we get 4 as the answer. So, Option A is correct.

07. Which of the following is not a valid variable name in Python?

  1. _var
  2. var_name
  3. var11
  4. 5var

Answer : D
Explanation: 5var is not a valid variable name in python.

08. What is the maximum length of an identifier in python?

  1. 32
  2. 31
  3. 63
  4. None of the above

Answer : D
Explanation: In python, the Identifier can be of any length. So, Option D is correct.

09. Which of the following declarations is incorrect?

  1. None Of the below
  2. _x = 2
  3. __x = 3
  4. __xyz__ = 5

Answer : A
Explanation: All declarations will execute successfully but at the expense of low readability.

10. What is the result of round(0.5) – round(-0.5)?

  1. 1.0
  2. 2.0
  3. 0
  4. None Of the above

Answer : B
Explanation: Python rounds off numbers away from 0 when the number to be rounded off is exactly halfway through. round(0.5) is 1 and round (-0.5) is -1 So, 1-(-1)=2.0

This Post Has 5 Comments

Leave a Reply