0% found this document useful (0 votes)
168 views

Unit 5

This document contains a quiz about Python concepts like lists, dictionaries, and loops. It asks 5 true/false questions testing understanding of how list and dictionary variables can be modified, list slicing, for loops, and accessing dictionary values. It then provides 4 exercises - to create a dictionary with names and emails, check for input in dictionary keys, print the sum of numbers in a list using a for loop, and print the first 3 elements of a list using slicing.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
168 views

Unit 5

This document contains a quiz about Python concepts like lists, dictionaries, and loops. It asks 5 true/false questions testing understanding of how list and dictionary variables can be modified, list slicing, for loops, and accessing dictionary values. It then provides 4 exercises - to create a dictionary with names and emails, check for input in dictionary keys, print the sum of numbers in a list using a for loop, and print the first 3 elements of a list using slicing.

Uploaded by

api-319267329
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

Unit 5 Quiz

1. Unlike string variables, which cannot be changed, list variables


and dictionary variables both can be changed.
A. True
B. False
2. List slicing means to cut the list into a smaller list containing part
of the original list.
A. True
B. False
3. List slicing from [0:6] will get me all the indexes starting from
zero up to six inclusive.
A. True
B. False
4. The for loop allows the user to go through each element in a
variable
A. True
B. False
5. If we want to print the value from key (Spam) in the dictionary
variable (python), we would write (print Spam[python])
A. True
B. False

Unit 5 Exercises
Create a dictionary that contains at least three random names as keys
and three emails as values. Afterwards, write a function to iterate over
this dictionary using for loop.
Using the same dictionary, write a function that checks to see if the
input already exists in the dictionarys keys. If it does exist, print
(Name already taken). Else, print (Name is available).
Create a list that contains at least 5 numbers. Then write a function
that uses for loop to print the sum of numbers in the list.
Using the same list, write a function that only prints the first three
elements of the list using list slicing.

You might also like