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:
- x ← 25
- x = 25
- x := 25
- int x = 25
- 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:
- False
- 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?
- int xx=7
- int x=7
- x=7
- 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
- 16
- 256
- 32768
- 65536
Answer : D Explanation: The statement is equivalent to 2^16. So, Option D is correct.
05. Which of the following statement is False?
- Variable names can be arbitrarily long.
- They can contain both letters and numbers.
- Variable name can begin with underscore.
- 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
- 4
- 4.5
- 4.0
- 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?
- _var
- var_name
- var11
- 5var
Answer : D Explanation: 5var is not a valid variable name in python.
08. What is the maximum length of an identifier in python?
- 32
- 31
- 63
- 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?
- None Of the below
- _x = 2
- __x = 3
- __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.0
- 2.0
- 0
- 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
Pingback: Python Basics (Multiple Choice Questions) MCQ - Python Interview objective questions| Python Quiz - cozmocard
Pingback: MS Excel MCQ Questions And Answers - cozmocard
Pingback: Java MCQ Questions and Answers - cozmocard
Pingback: Advance Java MCQ Questions and Answers - cozmocard
Pingback: Top Python Interview Questions And Answers - cozmocard