Chapter 6 - Part Two: How to Work with Lists and Tuples

Quiz
•
Instructional Technology
•
University
•
Easy
Kevin Tinsley
Used 4+ times
FREE Resource
39 questions
Show all answers
1.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What does the add_to_list() function do in the given code?
The add_to_list() function
def add_to_list(list, item):
list.append(item) # list object changed
The calling code in the main() function
# list object created
inventory = ["staff", "hat", "bread"]
add_to_list(inventory, "robe")
print(inventory) # ["staff", "hat", "bread", "robe"]
# NOTE: no need to return list object
Adds an element to the end of a list
Removes an element from a list
Sorts the list in ascending order
Clears all elements from the list
2.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Why is there no need to return the list object in the add_to_list() function?
The add_to_list() function
def add_to_list(list, item):
list.append(item) # list object changed
The calling code in the main() function
# list object created
inventory = ["staff", "hat", "bread"]
add_to_list(inventory, "robe")
print(inventory) # ["staff", "hat", "bread", "robe"]
# NOTE: no need to return list object
Because the list is immutable.
Because the list is passed by reference.
Because the function automatically returns the list.
Because the list is a global variable.
3.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Based on the hierarchy chart for the Movie List program, which of the following is not a function listed under 'main'?
display menu
list movies
add movie
search movie
4.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the 'display_menu' function in the Movie List program?
To add a new movie to the list
To display the list of movies
To show the available options to the user
To delete a movie from the list
5.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
Which command in the 'display_menu' function is used to add a movie?
list
add
del
exit
6.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
How does the 'list' function work in the Movie List program?
It adds a new movie to the list.
It removes a movie from the list.
It displays all movies in the list.
It sorts the movies in the list alphabetically.
7.
MULTIPLE CHOICE QUESTION
30 sec • 1 pt
What is the purpose of the 'delete' function in the Movie List program?
To add a new movie to the list
To remove a movie from the list
To update the details of a movie
To sort the movies in the list
Create a free account and access millions of resources
Similar Resources on Wayground
35 questions
Men's Haircutting

Quiz
•
University
35 questions
BSCS 4-2 - Elective 4 - Midterm Examination - 2023

Quiz
•
University
36 questions
CONCEPTOS TECNICOS DE REDES DE COMP.

Quiz
•
University
35 questions
BSIT 3-2 - IAS - Midterm Examination - 2023

Quiz
•
University
39 questions
ISDS 351 Midterm Practice Quiz

Quiz
•
University
40 questions
Unity Game Engine Overview

Quiz
•
University
37 questions
GCE Level 1 Scenarios

Quiz
•
University
35 questions
AI QUIZ (CLASS 10)

Quiz
•
10th Grade - University
Popular Resources on Wayground
10 questions
Video Games

Quiz
•
6th - 12th Grade
10 questions
Lab Safety Procedures and Guidelines

Interactive video
•
6th - 10th Grade
25 questions
Multiplication Facts

Quiz
•
5th Grade
10 questions
UPDATED FOREST Kindness 9-22

Lesson
•
9th - 12th Grade
22 questions
Adding Integers

Quiz
•
6th Grade
15 questions
Subtracting Integers

Quiz
•
7th Grade
20 questions
US Constitution Quiz

Quiz
•
11th Grade
10 questions
Exploring Digital Citizenship Essentials

Interactive video
•
6th - 10th Grade