Đề thi, bài tập trắc nghiệm online Lập trình Python – Đề 3

Đề 3 - Bài tập, đề thi trắc nghiệm online Lập trình Python

1. What will be the output of `print(bool(0), bool(1), bool(''))`?
2. What is the purpose of a generator in Python?
3. Which of the following data structures is immutable in Python?
4. Which of the following is NOT a built-in data type in Python?
5. In Python, what is the purpose of the `len()` function?
6. What is the output of `print('Hello'.replace('l', 'L'))`?
7. What does the `pip` command stand for in Python?
8. What is the role of the `self` parameter in Python class methods?
9. Which method is used to add an element to the end of a list in Python?
10. What is the purpose of the `__init__` method in a Python class?
11. Which of the following is a built-in function in Python for reading input from the user?
12. What is the purpose of the `try...except` block in Python?
13. Which of these loop types is NOT available in Python?
14. What is the output of the following Python code? ```python print(3 > 5 and 10 < 20) ```
15. What is the purpose of virtual environments in Python?
16. What does the `continue` statement do in a loop in Python?
17. What is the purpose of list comprehension in Python?
18. What is the primary purpose of the 'if __name__ == '__main__'' block in a Python script?
19. What is the difference between `==` and `is` operators in Python?
20. What is a dictionary in Python?
21. Which of the following statements about Python lists is FALSE?
22. What will be the output of the following Python code snippet? ```python x = 5 def modify_x(val): x = val modify_x(10) print(x) ```
23. What is the output of `print('Python'[1:4])`?
24. Which of the following is NOT a valid way to comment in Python?
25. What is a module in Python?
26. Which of the following is a correct way to open a file named 'myfile.txt' in read mode in Python?
27. What is a decorator in Python?
28. What is the output of `print(type([1, 2]))` in Python?
29. What is the purpose of the `pass` statement in Python?
30. What is the difference between function arguments `*args` and `**kwargs` in Python?