Top 20 Interview Python Questions
1. What will be the output of the following code?
a) 1
b) 4
c) Error
d) None
Answer: b) 4
2. What is the output of the following code?
a) True True False
b) False True False
c) False True True
d) True False False
Answer: b) False True False
3. What does the len()
function do in Python?
a) Returns the number of elements in a list or string
b) Checks if a list is empty
c) Computes the length of an integer
d) None of the mentioned
Answer: a) Returns the number of elements in a list or string
4. What will the following code output?
a) [1, 2]
b) [2, 3]
c) [1, 2, 3]
d) Error
Answer: b) [2, 3]
5. Which of the following is a mutable data type in Python?
a) String
b) Tuple
c) List
d) None of the mentioned
Answer: c) List
6. What will be the output of the following code?
a) hellohello
b) hello*2
c) Error
d) None
Answer: a) hellohello
7. What will be the output of the following code?
a) 4
b) 5
c) 6
d) Error
Answer: a) 4
8. What will be the output of the following code?
a) 1
b) 2
c) 3
d) 4
Answer: d) 4
9. What is the output of the following code?
a) <class 'list'>
b) <class 'dict'>
c) <class 'set'>
d) <class 'tuple'>
Answer: b) <class 'dict'>
10. What will be the output of the following code?
a) 3 6 9
b) 3 6
c) 4 7
d) Error
Answer: b) 3 6
11. What is the correct syntax to define a function in Python?
a) def functionName():
b) function functionName():
c) define functionName():
d) functionName define():
Answer: a) def functionName():
12. What is the output of the following code?
a) 64
b) 512
c) 8
d) 256
Answer: b) 512
13. What is the output of the following code?
a) Pytho
b) ytho
c) Pyth
d) Error
Answer: b) ytho
14. What is the data type of None
in Python?
a) int
b) float
c) bool
d) NoneType
Answer: d) NoneType
15. Which of the following statements is correct about Python?
a) Python is a compiled language
b) Python is an interpreted language
c) Python is both compiled and interpreted
d) None of the mentioned
Answer: b) Python is an interpreted language
16. What will be the output of the following code?
a) [1, 2, 3, 1, 2, 3]
b) [1, 2, 3, 2]
c) Error
d) None
Answer: a) [1, 2, 3, 1, 2, 3]
17. What is the output of the following code?
a) [1, 2, 3]
b) [1, 2, 3, 4]
c) Error
d) None
Answer: b) [1, 2, 3, 4]
18. What is the output of the following code?
a) None
b) 3
c) Error
d) KeyError
Answer: b) 3
19. What is the output of the following code?
a) Yes
b) No
c) Error
d) None
Answer: a) Yes
20. What will be the output of the following code?
a) 'a b c'
b) 'abc'
c) 'a,b,c'
d) Error
Answer: c) a,b,c
No comments:
If you have any doubt so you can comment me then i will 100% help you ,Through comment Chat