1. What is the output of the following code?
print(2 * 3 ** 2)
a) 36
b) 18
c) 12
d) 6
Answer: b) 18
2. Which data type is mutable in Python?
a) String
b) Tuple
c) List
d) Int
Answer: c) List
3. What does len([1, 2, [3, 4]]) return?
a) 2
b) 3
c) 4
d) Error
Answer: b) 3
4. What is the output of print(type({}))?
a) <class 'list'>
b) <class 'set'>
c) <class 'dict'>
d) <class 'tuple'>
Answer: c) <class 'dict'>
5. Which of the following is not a keyword in Python?
a) finally
b) class
c) define
d) yield
Answer: c) define
6. How do you start a comment in Python?
a) //
b) #
c) <!--
d) /*
Answer: b) #
7. What is the output of bool([])?
a) True
b) False
c) None
d) Error
Answer: b) False
8. Which function is used to get user input?
a) scan()
b) input()
c) get_input()
d) read()
Answer: b) input()
9. What does str(123) return?
a) 123
b) '123'
c) None
d) Error
Answer: b) '123'
10. What will 3 == 3.0 return?
a) True
b) False
c) Error
d) None
Answer: a) True
11. What is the output of print("Hello"[0])?
a) H
b) e
c) Hello
d) Error
Answer: a) H
12. Which operator is used for floor division in Python?
a) /
b) //
c) %
d) **
Answer: b) //
13. What is the result of 5 % 2?
a) 2
b) 1
c) 0
d) 5
Answer: b) 1
14. Which keyword is used to define a function in Python?
a) func
b) define
c) def
d) function
Answer: c) def
15. What does type(None) return?
a) <class 'None'>
b) <class 'null'>
c) <class 'NoneType'>
d) None
Answer: c) <class 'NoneType'>
0 Comments