1.Which of the following is an example of a Python data structure?
a) List
b) Integer
c) String
d) All of the above
Answer: d) All of the above
2. What is the output of the following Python code snippet?
a) 0 1 2 3 4 6 7 8 9
b) 0 1 2 3 4 5 6 7 8 9
c) 5
d) None of the above
Answer: a) 0 1 2 3 4 6 7 8 9
3. What does the "self" keyword represent in Python?
a) It refers to the instance of the class itself
b) It is used to refer to another instance of the same class
c) It is a reserved keyword and has no specific meaning
d) None of the above
Answer: a) It refers to the instance of the class itself
4. Which of the following is a Python package for scientific computing?
a) Pandas
b) NumPy
c) Matplotlib
d) All of the above
Answer: d) All of the above
5. What is the output of the following Python code snippet?
a) 3
b) 12
c) TypeError
d) None of the above
Answer: c) TypeError
6. What is the output of the following Python code snippet?
a) [1, 2, 3, 4, 5]
b) [1, 2, 3, 4]
c) [5, 4, 3, 2, 1]
d) None of the above
Answer: a) [1, 2, 3, 4, 5]
7. What is the output of the following Python code snippet?
x = 5
y = 10
if x > y:
print("x is greater than y")
else:
print("x is less than or equal to y")
a) x is greater than y
b) x is less than or equal to y
c) SyntaxError
d) None of the above
Answer: b) x is less than or equal to y
8. Which of the following is used to create a new object in Python?
a) Class
b) Object
c) Constructor
d) Method
Answer: c) Constructor
9. What is the output of the following Python code snippet?
a = [1, 2, 3, 4, 5]
print(a[1:3])
a) [1, 2, 3]
b) [2, 3]
c) [2, 3, 4]
d) [3, 4]
Answer: b) [2, 3]
10. What is the output of the following Python code snippet?
a = "Hello, World!"
print(a.upper())
a) hello, world!
b) HELLO, WORLD!
c) Hello, World!
d) None of the above
Answer: b) HELLO, WORLD!
0 Comments