COMP 1405 - Review Session Multiple Choice Questions
Note: these are created by a student, and are more meant for concept review, as opposed to being directly representative of the final
Sign in to Google to save your progress. Learn more
Given a 2D matrix ‘matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]’, what is the result of ‘matrix[1][2]’?
1 point
Clear selection
What is the result of the expression 'a+b' where 'a = [1,2,3]' and 'b = [4,5,6]'?
1 point
Clear selection
In Python, what is the purpose of the 'del' statement concerning variables?
1 point
Clear selection
What is the dimension of the matrix ‘[[1, 2, 3], [4, 5, 6]]’?
1 point
Clear selection
In recursive programming, what is the purpose of a base case?
1 point
Clear selection
What characterizes the evolution of the product in the iterative approach?
1 point
Clear selection
How many times will the following 'for' loop iterate?

for i in range(3):
    print(i)
1 point
Clear selection
What method do you use to remove the key-value pair ‘age’: 30 from the dictionary ‘employee_info’ = {‘name’: ‘John’, ‘age’: ‘30’}?
1 point
Clear selection
What is the output of the following following 'for' loop?

for i in range(1, 5, 2):
    print(i)
1 point
Clear selection
Which representation is more efficient for checking the existence of an edge between two vertices?
1 point
Clear selection
Given a 2D matrix ‘matrix = [[1, 2, 3], [4, 5, 6], [7, 8, 9]]’, what does ‘matrix[1:][0]’ result in?
1 point
Clear selection
How does the number of comparisons performed by selection sort compare to bubble sort for the same input?
1 point
Clear selection
What does the expression 'hello'* 3 evaluate to?
1 point
Clear selection
Which of the following is an example of an immutable data type in Python
1 point
Clear selection
How do you check if an element exists in a list 'my_list'?
1 point
Clear selection
What is the primary goal of the iterative approach in project management?
1 point
Clear selection
How do you remove an element at a specific index from a list 'my_list'?
1 point
Clear selection

This recursive function correctly reverse a given string ‘s’

def reverse_string(s):

    if len(s) == 1:

        return ""

    return reverse_string(s[1:]) + s[0]

1 point
Clear selection
How do you check if a key ‘salary’ exists in the dictionary ‘employee_info = {‘name’: ‘John’, ‘age’: ‘30’}’
1 point
Clear selection
What data type is the result of the expression '5/2' in Python?
1 point
Clear selection
What does the expression '"hello world".split()' return?
1 point
Clear selection
What is the output of the following code snippet?
________

x = 8

y = 3

result = x/y

print(result)

1 point
Clear selection
When is insertion sort most efficient in terms of time complexity?
1 point
Clear selection
When is a recursive approach appropriate to use?
1 point
Clear selection
What is the “worst-case” number of passes that a bubble sort performs in order to sort an array of length n?
1 point
Clear selection
In iterative project management what is the role of planning throughout the project lifecycle?
1 point
Clear selection
What if the purpose of the 'continue' statement in a 'while' loop?
1 point
Clear selection
What is the purpose of the 'break' statement in a 'while' loop?
1 point
Clear selection
What is the primary purpose of the 'type()' function in Python?
1 point
Clear selection
What are the goals of iterative approaches?
1 point
Clear selection
Which of the following is the correct Python code to calculate when dividing 17 by 4?
1 point
Clear selection
Which method is used to convert a string to lowercase?
1 point
Clear selection
What is the purpose of the 'elif'(else if) clause in an 'if-elif-else' statement?
1 point
Clear selection
How do you add a new row ‘[10, 11, 12]’ to the matrix ‘[[1, 2, 3], [4, 5, 6], [7, 8, 9]]’?
1 point
Clear selection

How are edge weights typically stored in adjacency lists?

1 point
Clear selection
Consider the following nested if-else statement:

x = 10
y = 5

if x>5:
    if y>3:
        results = "A"
    else: 
        result = "B"
else:
    result = "C"
1 point
Clear selection
What is the difference between '==' and 'is' when comparing variables in Python?
1 point
Clear selection
What does the 'append()' method do for a list?
1 point
Clear selection
What does the expression '5>3 or 2<1'
1 point
Clear selection
In Python, what is the purpose of the 'assert' statement?
1 point
Clear selection

Given a dictionary ‘student = {‘name’: ‘Alice’, ‘age’: 22, ‘grade’: ’A’}’, how do you access Alice’s age?

1 point
Clear selection
What does the expression '4+5*2/2'
1 point
Clear selection
What is the scope of a variable in Python?
1 point
Clear selection
What is the result of the expression ‘5 + 3 * 2 ’?
1 point
Clear selection
In the worst-case scenario, when is bubble sort the most efficient?
1 point
Clear selection

Which representation allows for easier addition of new vertices in a graph?

1 point
Clear selection
How can you concatenate two strings 'str1' and 'str2'?
1 point
Clear selection
Which of the following is the correct way to calculate the floor division of 10 by 3 in Python?
1 point
Clear selection
What is the difference between iterations and increments in an iterative project?
1 point
Clear selection
What is the output of the following nested 'for' loop?

for i in range(2):
   for j in range(3):
        print(i+j, end = " ")
1 point
Clear selection
What does the expression 'len('Python')' return?
1 point
Clear selection
What is the purpose of the 'else' clause in an 'if-else' statement?
1 point
Clear selection
Which of the following statements is true regarding the 'range' function in a 'for' loop?
1 point
Clear selection
In Python, what is the purpose of the 'id()' function when applied to a variable?
1 point
Clear selection
Which of the following data types is mutable in Python?
1 point
Clear selection
Submit
Clear form
This content is neither created nor endorsed by Google. Report Abuse - Terms of Service - Privacy Policy