Python Variables Quiz (original) (raw)
How do you concatenate two strings in Python?
What is the purpose of the __dict__ attribute in Python?
- To access the dictionary of a list
- To store the attributes of an object
- To define a dictionary in Python
- To convert a dictionary to a list
How do you create a dictionary using a comprehension in Python?
- {key: value for key, value in iterable}
How do you create a multiline string in Python?
- "This is a multiline string"
- 'This is a multiline string'
- """This is a multiline string"""
How do you convert a floating-point number to an integer in Python?
How do you convert a list of strings to a single string in Python?
What is the output of the following code?
x = [1, 2, 3, 4]
y = filter(lambda a: a % 2 == 0, x)
print(list(y))
What is the purpose of the enumerate() function in Python?
- To get the index and value of each item in an iterable
- To count the occurrences of an element in an iterable
- To enumerate through a list
- To enumerate through a dictionary
How do you check if a key is present in a dictionary?
How do you find the length of a list in Python?
There are 24 questions to complete.
Take a part in the ongoing discussion