0% found this document useful (0 votes)
12 views

Here are 10 more Python multiple-45

Uploaded by

Prajwal HC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
12 views

Here are 10 more Python multiple-45

Uploaded by

Prajwal HC
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 4

Here are 15 more Python multiple-choice questions:

1. What is the output of the following code?

print(type([]))

a) <class 'list'>
b) <class 'tuple'>
c) <class 'dict'>
d) <class 'set'>

Answer: a) <class 'list'>

2. Which keyword is used to define a function in Python?

a) func
b) def
c) lambda
d) function

Answer: b) def

3. What will be the output of the following code?

x = [1, 2, 3]

y = x.copy()

y.append(4)

print(x)

a) [1, 2, 3]
b) [1, 2, 3, 4]
c) Error
d) None

Answer: a) [1, 2, 3]

4. What does the is operator do in Python?

a) Compares values of two objects


b) Checks if two variables refer to the same object
c) Checks for type compatibility
d) Performs bitwise operations

Answer: b) Checks if two variables refer to the same object


5. What is the result of bool([]) in Python?

a) True
b) False
c) None
d) Error

Answer: b) False

6. What will be the output of the following code?

print(10 / 3)

a) 3.0
b) 3
c) 3.33
d) 3.3333333333333335

Answer: d) 3.3333333333333335

7. What method is used to find the position of an item in a list?

a) index()
b) find()
c) locate()
d) position()

Answer: a) index()

8. What is the purpose of the pass statement in Python?

a) To pause the program execution


b) To act as a placeholder for future code
c) To skip iterations in a loop
d) To terminate a loop

Answer: b) To act as a placeholder for future code

9. How can you remove an item from a set?

a) remove()
b) discard()
c) Both a and b
d) None of the above

Answer: c) Both a and b


10. Which of the following is true about Python variables?

a) Variables need to be declared with a type


b) Variable names can start with a number
c) Variables are dynamically typed
d) Variable names can contain spaces

Answer: c) Variables are dynamically typed

11. What will be the output of the following code?

x = [1, 2, 3, 4]

print(x[:2])

a) [1, 2]
b) [1, 2, 3]
c) [3, 4]
d) [2, 3, 4]

Answer: a) [1, 2]

12. What is the output of the following code?

print("Python".upper())

a) PYTHON
b) python
c) Error
d) None

Answer: a) PYTHON

13. What will the following code print?

a = {'x': 1, 'y': 2}

a['z'] = 3

print(a)

a) {'x': 1, 'y': 2, 'z': 3}


b) {'x': 1, 'y': 2}
c) {'z': 3}
d) Error

Answer: a) {'x': 1, 'y': 2, 'z': 3}

14. What is the correct syntax for a for loop in Python?


a)

for (i = 0; i < 10; i++):

b)

for i in range(10):

c)

for (i: 0 to 10):

d)

for i = 1 to 10:

Answer: b)

for i in range(10):

15. What is the output of the following code?

x = "Python"

print(x[::-1])

a) Python
b) nohtyP
c) Error
d) None

Answer: b) nohtyP

Let me know if you'd like more!

You might also like