Mini Quiz II Review Exercises

Mini Quiz II Review Exercises

University

9 Qs

quiz-placeholder

Similar activities

What types of news media do you know?

What types of news media do you know?

University - Professional Development

4 Qs

 Mga bahagi at kahalagahan ng komputyer

Mga bahagi at kahalagahan ng komputyer

University

10 Qs

Review of Reading Terminology

Review of Reading Terminology

University

10 Qs

Weekly Contest #12 - TechXNinjas

Weekly Contest #12 - TechXNinjas

University

10 Qs

Python Programming Quiz

Python Programming Quiz

University

10 Qs

Recursions

Recursions

University

11 Qs

Google Slides Quiz

Google Slides Quiz

University

10 Qs

LanYaolei

LanYaolei

University

10 Qs

Mini Quiz II Review Exercises

Mini Quiz II Review Exercises

Assessment

Quiz

Education

University

Easy

Created by

Kyriaki Mengoudi

Used 3+ times

FREE Resource

9 questions

Show all answers

1.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

Which of the statements below are reasons we might iterate over a list by position, rather than by value? Select all that apply.

To modify the values in a list.

We never need to iterate by position.

To make sure we don’t modify the values in a list.

To iterate over two related lists at the same time

2.

OPEN ENDED QUESTION

3 mins • 1 pt

What does the variable new_list contain after the following code runs?

values = [2, 4, 6, 8, 10, 12] new_list = [] for num in values[:3]: new_list.append(num * 2)

Evaluate responses using AI:

OFF

3.

OPEN ENDED QUESTION

3 mins • 1 pt

What does the variable numbers contain after the following code runs? numbers = [5, 15, 25, 35, 45] for i in range(1, len(numbers)): numbers[i] = numbers[i] + numbers[i - 1]

Evaluate responses using AI:

OFF

4.

MULTIPLE CHOICE QUESTION

30 sec • 1 pt

Which of the following Python snippets is best for calling a function named foo that takes no parameters and returns an int? Select only one option (the best answer) below.

foo = ()

foo()

foo = def()

result = foo()

5.

OPEN ENDED QUESTION

3 mins • 1 pt

What will the following Python code print? def func(p1): x = p1 * 2 return x def main(): x = 4 func(x) print(x * 2) print(func(x * 2)) main()

Evaluate responses using AI:

OFF

6.

OPEN ENDED QUESTION

3 mins • 1 pt

What will the following Python code print? def big_vals(lst, k): new_lst = [] for num in lst: if num > k: new_lst.append(num) return new_lst def main(): results = big_vals([1, 2, 3, 4, 5], 3) print(results) main()

Evaluate responses using AI:

OFF

7.

MULTIPLE SELECT QUESTION

30 sec • 1 pt

For the 2D list lst = [[2, 4, 6, 8], [1, 2, 3, 4]], circle all the expressions below that produce no error and access a one-dimensional list.

lst

lst[0]

lst[1]

lst[1][1]

lst[2]

8.

OPEN ENDED QUESTION

3 mins • 1 pt

What would the code below print to the terminal? lst = [[2, 4, 6, 8], [1, 2, 3, 4]] for i in range(len(lst)): print(lst[i][1])

Evaluate responses using AI:

OFF

9.

OPEN ENDED QUESTION

3 mins • 1 pt

What would the code below print to the terminal? def count_string(names, s): count = 0 for i in range(len(names)): for j in range(len(names[i])): if names[i][j] == s: count += 1 return count def main(): lst = [["carol", "grizz"], ["carol", "choux"]] name = "carol" print(count_string(lst, name)) main()

Evaluate responses using AI:

OFF