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

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

University

39 Qs

quiz-placeholder

Similar activities

Present Perfect

Present Perfect

University

35 Qs

TSA Chapter team

TSA Chapter team

KG - Professional Development

34 Qs

Quiz # 5- Networking

Quiz # 5- Networking

University

35 Qs

MATLAB 6072

MATLAB 6072

University

43 Qs

Topic 13 revision

Topic 13 revision

12th Grade - University

34 Qs

Kisi-Kisi Ujian Kelas 7

Kisi-Kisi Ujian Kelas 7

1st Grade - University

35 Qs

Automotive Electrical Systems: a 2021 Revision Aid

Automotive Electrical Systems: a 2021 Revision Aid

10th Grade - University

40 Qs

US-SMKN 1 Ponjong-2021

US-SMKN 1 Ponjong-2021

12th Grade - University

40 Qs

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

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

Assessment

Quiz

Instructional Technology

University

Practice Problem

Easy

Created by

Kevin Tinsley

Used 4+ times

FREE Resource

AI

Enhance your content in a minute

Add similar questions
Adjust reading levels
Convert to real-world scenario
Translate activity
More...

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Media Image

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

Create resources

Host any resource

Get auto-graded reports

Google

Continue with Google

Email

Continue with Email

Classlink

Continue with Classlink

Clever

Continue with Clever

or continue with

Microsoft

Microsoft

Apple

Apple

Others

Others

By signing up, you agree to our Terms of Service & Privacy Policy

Already have an account?