0% found this document useful (0 votes)
13 views2 pages

Python MCQs: Data Types & Functions

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)
13 views2 pages

Python MCQs: Data Types & Functions

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

Here are 5 more Python multiple-choice questions:

1. What is the output of the following code?


x = [1, 2, 3, 4]
print(x[-1])
a) 4
b) 3
c) IndexError
d) None
Answer: a) 4

2. Which of the following is not a valid Python data type?


a) list
b) dictionary
c) tuple
d) array
Answer: d) array

3. How can you get all the keys from a dictionary my_dict?
a) my_dict.keys()
b) keys(my_dict)
c) my_dict.all_keys()
d) my_dict.get_keys()
Answer: a) my_dict.keys()

4. What is the output of the following code?


x = "Hello"
y = "World"
print(x + " " + y)
a) HelloWorld
b) Hello World
c) Hello+World
d) Syntax Error
Answer: b) Hello World

5. Which of the following functions can be used to convert a string to lowercase?


a) toLowerCase()
b) lowercase()
c) tolower()
d) lower()
Answer: d) lower()

Let me know if you need more!

You might also like