0% found this document useful (0 votes)
134 views2 pages

Unit 7

This document contains a quiz on list methods in Python and exercises to practice working with lists. The quiz questions cover appending to lists, mutability of lists, the range function, joining lists with +, and nesting lists. The exercises ask the student to write functions that multiply each element of a list by two, print only even numbers from a list, and check if two lists contain any common numbers.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
134 views2 pages

Unit 7

This document contains a quiz on list methods in Python and exercises to practice working with lists. The quiz questions cover appending to lists, mutability of lists, the range function, joining lists with +, and nesting lists. The exercises ask the student to write functions that multiply each element of a list by two, print only even numbers from a list, and check if two lists contain any common numbers.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

Unit 7 Quiz

1. I can append more than one element to a list at a time using


append() function.
A. True
B. False
2. Lists are mutable (can be changed).
A. True
B. False
3. Printing range(0,10,2) will get me..
A. 2, 4, 6, 8, 10
B. 0, 2, 4, 6, 8, 10
C. 0, 2, 4, 6, 8
4. I can join two lists using + sign. So [1,2,3] + [4,5,6] will give
me [1,2,3,4,5,6].
A. True
B. False
5. A list cannot another list within itself. So [[1,2], [3,4]] for
example.
A. True
B. False

Unit 7 Exercises
Create a list containing at least three numbers. Then write a function
that will multiply each element in the list by two and print the changed
list. So entering [1,2,3] as input will print [1,4,9].
Create a list containing at least five numbers. Then write a function
that prints only even numbers in the list. (Hint: use % operator to
check for even numbers)
Create a function that accepts two lists containing integers as
parameters. If the two lists have any numbers in common, return True.
Otherwise, return False. (Hint: This one is tricky. Try using a for loop
within another for loop. AKA loop through one of the lists and for each
element, loop through the other list and compare to see if this element
equals any of the integers in the other list).

You might also like