
PYTHON PROGRAMMING
Quiz by Dr.M.S.Jeyalakshmi
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
- Q1
What is the output of the following code?
my_dict = {"name": "Alice", "age": 25} my_dict["age"] = 30 print(my_dict)
{"name": "Alice", "age": 25}
{"name": "Alice", "age": "30"}
{"name": "Alice", "age": 45}
{"name": "Alice", "age": 30}
30s - Q2
Which method is used to get a list of all the keys in a dictionary?
getkeys()
keys()
dict_keys()
all_keys()
30s - Q3
What is the correct way to access a value from a dictionary using a key?
my_dict.get(key)
my_dict[key]
my_dict{key}
my_dict.get(key)and my_dict[key]
30s - Q4
Which of the following is true about tuples in Python?
Tuples are slower than lists for performance.
Tuples are ordered collections.
Tuples cannot contain mixed data types.
Tuples are mutable (can be changed after creation).
30s - Q5
How do you access the first element of the tuple my_tuple = (10, 20, 30)?
my_tuple.first()
my_tuple(0)
my_tuple[1]
my_tuple[0]
30s - Q6
What will be the result of the following code?
4
3
2
1
30s - Q7
Which of the following methods can be used to combine two tuples in Python?
tuple1.concat(tuple2)
tuple1.extend(tuple2)
tuple1 + tuple2
tuple1.append(tuple2)
30s - Q8
Which of the following is the correct syntax to create a list in Python?
list = [1, 2, 3]
list = {1, 2, 3}
list = 1, 2, 3
list = (1, 2, 3)
30s - Q9
What will be the output of the following code?
[1, 2, 3, 10]
[1, 2, 10, 4]
[1, 2, 3, 4, 10]
Error: TypeError
30s - Q10
Which method is used to sort a list in ascending order?
order()
sort()
reverse()
sorted()
30s