Here are 10 additional Python multiple-choice questions:
1. What is the output of the following code?
print(type([1, 2, 3]))
a) <class 'list'>
b) <class 'tuple'>
c) <class 'array'>
d) <class 'set'>
Answer: a) <class 'list'>
2. What does the // operator do in Python?
a) Divides and returns the remainder
b) Divides and returns the quotient as an integer
c) Divides and returns the quotient as a float
d) Performs exponential calculation
Answer: b) Divides and returns the quotient as an integer
3. What is the correct syntax to check if key "name" exists in a dictionary person?
a) "name" exists in person
b) "name" in person
c) "name" in keys(person)
d) person.has_key("name")
Answer: b) "name" in person
4. What is the correct way to create a set in Python?
a) {}
b) set([])
c) set()
d) Both b and c
Answer: d) Both b and c
5. Which of the following methods can be used to add an element to a set?
a) append()
b) add()
c) insert()
d) extend()
Answer: b) add()
6. What is the output of the following code?
x = "Python"
print(x[0:3])
a) Pyt
b) yth
c) on
d) Pyth
Answer: a) Pyt
7. What does the following code snippet do?
for i in range(5):
print(i, end=" ")
a) Prints 0 1 2 3 4
b) Prints 1 2 3 4 5
c) Prints 0, 1, 2, 3, 4
d) Syntax error
Answer: a) Prints 0 1 2 3 4
8. How do you create a comment in Python?
a) // This is a comment
b) /* This is a comment */
c) # This is a comment
d) <!-- This is a comment -->
Answer: c) # This is a comment
9. What is the purpose of the is operator in Python?
a) Compare values of two variables
b) Check if two variables refer to the same object
c) Assign one variable to another
d) Check if a value exists in a list
Answer: b) Check if two variables refer to the same object
10. Which of the following is used to handle exceptions in Python?
a) try-except
b) if-else
c) try-catch
d) throw-catch
Answer: a) try-except
Let me know if you need further assistance!