Debug School

Akanksha
Akanksha

Posted on

Top 30 Python Interview Questions with Answers

1. What is Python?

A. A high-level programming language
B. A low-level programming language
C. A hardware component
D. A data structure
Answer: A

2. What is the output of print(2 + 3 * 5)?

A. 10
B. 25
C. 17
D. 7
Answer: C

3. Which of the following is not a core data type in Python?

A. Lists
B. Tuples
C. Dictionary
D. Set
Answer: D

4. Which statement is used to exit a loop in Python?

A. break
B. stop
C. exit
D. end
Answer: A

5. Which of the following is a valid Python identifier?

A. 1variable
B. variable_1
C. var-1
D. all of the above
Answer: B

6. What is the result of 5 / 2 in Python 3?

A. 2.5
B. 2
C. 2.0
D. 2.2
Answer: A

7. Which function is used to read a line of text from the user in Python?

A. read()
B. readline()
C. input()
D. get()
Answer: C

8. Which data structure in Python is ordered and mutable?

A. List
B. Tuple
C. Set
D. Dictionary
Answer: A

9. What is the output of print("Hello " + 3 * "World")?

A. Hello World
B. HelloWorld
C. Hello WorldWorldWorld
D. Error
Answer: C

10. Which of the following is true about Python's pass statement?

A. It does nothing
B. It stops the program
C. It raises an exception
D. It returns a value
Answer: A

11. What does the len() function in Python do?

A. Returns the length of a string
B. Returns the number of items in a list
C. Returns the size of a file
D. All of the above
Answer: D

12. What is the output of print("Python"[::-1])?

A. nohtyP
B. Python
C. P
D. Error
Answer: A

13. Which keyword is used for function definition in Python?

A. define
B. def
C. function
D. define_function
Answer: B

14. Which statement is used to raise an exception manually in Python?

A. raise
B. throw
C. except
D. try
Answer: A

15. What is the output of print(3 ** 4)?

A. 12
B. 81
C. 64
D. 27
Answer: B

16. Which of the following is not a standard library in Python?

A. os
B. math
C. standard
D. time
Answer: C

17. What is the result of 10 == "10" in Python?

A. True
B. False
C. Error
D. None
Answer: B

18. What does the strip() method do for strings in Python?

A. Removes leading and trailing spaces
B. Removes all spaces
C. Converts the string to uppercase
D. Converts the string to lowercase
Answer: A

19. Which of the following is an immutable data type in Python?

A. List
B. Set
C. Tuple
D. Dictionary
Answer: C

20. What is the output of print("Python".lower())?

A. PYTHON
B. python
C. PyThOn
D. Error
Answer: B

21. What is the output of print(4 % 2)?

A. 0
B. 1
C. 2
D. 4
Answer: A

22. Which operator is used for exponentiation in Python?

A. **
B. ^
C. %
D. /
Answer: A

23. Which of the following is a built-in function in Python for type conversion?

A. int()
B. float()
C. str()
D. all of the above
Answer: D

24. What is the output of print("Hello".find("l"))?

A. 0
B. 2
C. 3
D. -1
Answer: B

25. What is the output of print([1, 2, 3] + [4, 5])?

A. [1, 2, 3, 4, 5]
B. [1, 2, 3, [4, 5]]
C. [1, 2, 3, 4, [5]]
D. Error
Answer: A

26. What is the result of not True in Python?

A. True
B. False
C. None
D. Error
Answer: B

27. Which function is used to sort a list in-place in Python?

A. sort()
B. sorted()
C. order()
D. sort_in_place()
Answer: A

28. What is the output of print("abc def".split())?

A. ['abc', 'def']
B. ['abc def']
C. 'abc def'
D. Error
Answer: A

29. Which keyword is used for exception handling in Python?

A. try
B. catch
C. handle
D. exception
Answer: A

30. What does the join() method do for strings in Python?

A. Joins a list of strings into one string
B. Splits a string into a list
C. Converts the string to uppercase
D. Converts the string to lowercase
Answer: A

Top comments (0)