Posted on

## Python Multiple Choice Questions(MCQ) and Answers

1. Which of the following is a Python tuple?

a) [1, 2, 3]
b) (1, 2, 3)
c) {1, 2, 3}
d) {}

Explanation: Tuples are represented with round brackets[/bg_collapse]

2. What is the output of this expression, 31*3?

a) 3
b) 9
c) 27
d) 1

Explanation: First this will solve 1**3 because exponential has higher precedence than multiplication, so 1**3 = 1 and 3*1 = 3. Final answer will be 3.[/bg_collapse]

3. Which of the following words cannot be a variable in python language?

a) _val

b) try

c) try

d) val

Explanation: “try” is a keyword.[/bg_collapse]

4. Is Python case sensitive when dealing with identifiers?

a) yes
b) no
c) machine dependent
d) none of the mentioned

Explanation: Case sensitive is always significant.[/bg_collapse]

5. What is the type of inf?

a) Integer
b) Boolean
c) Float
d) Complex

Explanation: Infinity(inf) is a special case of floating point numbers. It can be obtained by float(‘inf’).[/bg_collapse]

6. Which one of these is floor division?

a) /
b) //
c) %
d) None of the mentioned

Explanation: When both of the operands are integer then python chops out the fraction part and gives you the round off value, to get the accurate answer use floor division.[/bg_collapse]

7. What is the maximum possible length of an identifier?

a) 26
b) 12
c) 100
d) None of these above

Explanation: The maximum possible length of an identifier is not defined in the python language. It can be of any number.[/bg_collapse]

8. What will be the output of the following Python code?

``````i = 1
while True:
if i%3 == 0:
break
print(i)
i + = 1``````

a) 1 2
b) 1 2 3
c) error
d) none of the mentioned

Explanation: SyntaxError, there shouldn’t be a space between + and = in +=.[/bg_collapse]

9. What does 3 ^ 4 evaluate to?

a) 7
b) 0.75
c) 12
d) 81

``float(22//3+3/3)``