0% found this document useful (0 votes)
111 views1 page

Unit 8

This document contains a quiz on concepts from Unit 8 including while loops, break statements, iterating through lists and dictionaries. It also provides exercises to write functions that reverse a list, check if a string is a palindrome, and return the longest word in a string. The quiz questions cover topics like while loop conditions, using break to exit a loop, and iterating through different data types. The exercises ask the reader to write Python functions to manipulate and analyze strings and lists.

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)
111 views1 page

Unit 8

This document contains a quiz on concepts from Unit 8 including while loops, break statements, iterating through lists and dictionaries. It also provides exercises to write functions that reverse a list, check if a string is a palindrome, and return the longest word in a string. The quiz questions cover topics like while loop conditions, using break to exit a loop, and iterating through different data types. The exercises ask the reader to write Python functions to manipulate and analyze strings and lists.

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/ 1

Unit 8 Quiz

1. While loop will loop forever as long as the condition is False.


A. True
B. False
2. An infinite loop does exist.
A. True
B. False
3. What
A.
B.
C.

does the break statement do?


It stops the whole execution from running
It stops the current function from running
It stops the current loop/indentation from running

4. If we want to iterate through a list, we can use both for loop and
while loop to accomplish this.
A. True
B. False
5. In order to iterate through a dictionary, we use keys instead of
indexes.
A. True
B. False

Unit 8 Exercise
Create a list containing at least 3 elements. Write a function that
returns the list backwards.
Write a function that takes in one argument as a string. If the reversed
string is the same as the original string (ex: racecar spelled backwards
is still racecar), return True. Otherwise, return False.
Write a function that takes in one string argument and returns the
largest word in the string. If there are two or more words that are the
same length, return the first word from the string with that length.
Ignore punctuations.
Ex) fun&!! Time will return Time
I love dogs will return love

You might also like