Unit II MCQ -Python
Unit II MCQ -Python
a) no
b) yes
c) machine dependent
d) none of the mentioned
Answer: b
2. Which keyword is used for function in Python language?
a) Function
b) def
c) Fun
d) Define
Answer: b
3. Which of the following character is used to give single-line comments in Python?
a) //
b) #
c) !
d) /*
Answer: b
4. 15. What will be the output of the following Python code snippet if x=1?
x<<2
a) 4
b) 2
c) 1
d) 8
Answer: a
5. What is the order of precedence in python?
a) Exponential, Parentheses, Multiplication, Division, Addition, Subtraction
b) Exponential, Parentheses, Division, Multiplication, Addition, Subtraction
c) Parentheses, Exponential, Multiplication, Addition, Division, Subtraction
d) Parentheses, Exponential, Multiplication, Division, Addition, Subtraction
Answer: d
6. Which of the following functions is a built-in function in python?
a) factorial()
b) print()
c) seed()
d) sqrt()
Answer: b
7. What will be the output of the following Python function?
min(max(False,-3,-4), 2,7)
a) -4
b) -3
c) 2
d) False
Answer: d
Explanation: The function max() is being used to find the maximum value from
among -3, -4 and false. Since false amounts to the value zero, hence we are left with
min(0, 2, 7) Hence the output is 0 (false).
8. Which of the following is not a core data type in Python programming?
a) Tuples
b) Lists
c) Class
d) Dictionary
Answer: c
9. Which of the following statements is used to create an empty set in Python?
a) ( )
b) [ ]
c) { }
d) set()
Answer: d
10. What is the maximum possible length of an identifier in Python?
a) 79 characters
b) 31 characters
c) 63 characters
d) none of the mentioned
Answer: d
11. What are the two main types of functions in Python?
a) System function
b) Custom function
c) Built-in function & User defined function
d) User function
Answer: c
12. Which of the following is a Python tuple?
a) {1, 2, 3}
b) {}
c) [1, 2, 3]
d) (1, 2, 3)
Answer: d
13. What will be the output of the following Python expression?
round(4.576)
a) 4
b) 4.6
c) 5
d) 4.5
Answer: c
14. What is output of print(math.pow(3, 2))?
a) 9.0
b) None
c) 9
d) None of the mentioned
Answer: a
15. Which one of these is floor division?
a) /
b) //
c) %
d) None of the mentioned
Answer: b
16. Operators with the same precedence are evaluated in which manner?
a) Left to Right
b) Right to Left
c) Can’t say
d) None of the mentioned
Answer: a
17. What is the output of this expression, 3*1**3?
a) 27
b) 9
c) 3
d) 1
Answer: c
18. What will be the output of the following Python code?
1.>>>str="hello"
2.>>>str[:2]
3.>>>
a) he
b) lo
c) olleh
d) hello
Answer: a
Answer: a
Answer: a