Dsa Reviewer 1
Dsa Reviewer 1
Which of
the following codes correctly initializes an empty dictionary?
b.my_dict = dict()
For a list variable initialized as 'list = [6, 1, 15, 6, 13, 15, 4, 8, 12, 5]', how many
elements does it contain?
b.10
Given a list variable in Python initialized as 'list = [6, 1, 15, 6, 13, 15, 4, 8, 12, 5]',
what is its initial content?
b.[6, 1, 15, 6, 13, 15, 4, 8, 12, 5]
Given a Python dictionary where keys are integer numbers and values are their
corresponding names in English (e.g., 1: "One", 2: "Two", etc.), what would be the
value associated with the key '3'?
c."Three"
Given a Python dictionary where keys are numbers from 1 to 4, and values are the
corresponding names in English. What is the type of the keys in this dictionary?
c.Integers
Given the Python code snippet 'list = [0] * size', what is its function?
c.To create a list of 'size' number of zeros
Given the Python code snippet 'sum = list[1] + list[4] + list[8]', what is it
computing?
a.The sum of the second, fifth, and ninth elements of the list
How can we get the number of items (key-value pairs) in a dictionary in Python?
c.Using the len() function
What is the correct way to access the value 'Alejandro' from my_dict?
my_dict["A"]
What is the initial content of the list in the Python code 'list = [2.3, 7.72, 5.94, 7.85, 5.13,
5.29, 8.84, 4.1, 10.31, 2.96]'?
[2.3, 7.72, 5.94, 7.85, 5.13, 5.29, 8.84, 4.1, 10.31, 2.96]
What is the output of the 'greet()' function in the provided code?
"Hello, there!"
What is the output of the print statement in the given Python code snippet 'print("Product:
%.2f" % (list[0] * list[4]))'?
"Product: 11.79"
What is the output of the print statement in the given Python code snippet 'print("Sum of
first and last:", list1[0] + list2[-1])'?
It prints the sum of the first element of list1 and the last element of list2
What is the primary purpose of a function in Python?
To perform a specific task efficiently.
What is the purpose of a dictionary in Python?
To store data in key-value pairs.
What is the purpose of Python lists?
To group related data, provide dynamic storage and retrieval of elements, and for
iteration and processing
What is the purpose of the 'dict()' function in Python?
To create an empty dictionary
What is the purpose of the return statement in a Python function?
To determine the result that the function should produce.
What is the purpose of using for i in range(size): in Python?
It runs a loop size times.
What is the starting index of a Python list?
0
What role do functions play in Python programming?
They provide modularity, code reusability, and abstraction.
What value does the 'add' function return when called with arguments 10 and 20?
30
What will 'int(input())' in a Python script do when executed?
It will convert the input from the user to an integer
What will be printed out if the user enters 100 when asked to "Enter a new value for
key_1: "?
{ "key_0": 4, "key_1": 100, "key_2": 7, "key_3": 1, "key_4": 5, "key_5": 10 }
What will be the output of print(person.get("address", "Unknown")) if "address" key does
not exist in the person dictionary?
"Unknown"
What will be the output of the following command: print(my_dict.get('B'))?
Belantar
Which built-in Python function is used to convert a user's input to an integer?
int()
Which function is used to create a dictionary in Python?
dict()
Which of the following best describes function modularity?
Breaking down a program into smaller, reusable parts.
Which of the following is the correct way to access the third element of a Python list
named 'numbers'?
numbers[2]
Why are lists important in Python programming?
Lists help in organizing and processing data effectively, are dynamic and flexible, and
are used widely in various Python applications