11.11 Exercises

From Foundations of Python ProgrammingGNU FDL 1.3Original pagePython1 class period4 exercisesNot autograded

README.md

11.11 Exercises

Read first in the book: 11.9 When to use a dictionary, 11.10 Glossary.

Exercise 1

Predict what will print out from the following code. If a line causes a run-time error, comment it out and see whether the rest of your predictions were correct.

Open the 01 folder and edit main.py. This one is not graded, so check it yourself.

Check your understanding: a fill-in-the-blank question in the book.

Exercise 2

Avast! Try this one swabbies. Here's a table of English to Pirate translations

EnglishPirate
sirmatey
hotelfleabag inn
studentswabbie
boymatey
madamproud beauty
professorfoul blaggart
restaurantgalley
youryer
excusearr
studentsswabbies
arebe
lawyerfoul blaggart
theth'
restroomhead
myme
helloavast
isbe
manmatey

Write a program that asks the user for a sentence in English and then translates that sentence to Pirate.

Open the 02 folder and edit main.py. This one is not graded, so check it yourself.

Check your understanding: a fill-in-the-blank question in the book.

Exercise 3

Write a program that finds the most used 7 letter word in scarlet3.txt.

Open the 03 folder and edit main.py. This one is not graded, so check it yourself.

Check your understanding: a multiple-choice question in the book.

Exercise 4

Write a program that allows the user to enter a string. It then prints a table of the letters of the alphabet in alphabetical order which occur in the string together with the number of times each letter occurs. Case should be ignored. A sample run of the program might look this this:

Please enter a sentence: ThiS is String with Upper and lower case Letters.
a  2
c  1
d  1
e  5
g  1
h  2
i  4
l  2
n  2
o  1
p  2
r  4
s  5
t  5
u  1
w  2
$

Open the 04 folder and edit main.py. This one is not graded, so check it yourself.

Check your understanding: a fill-in-the-blank question in the book.

For teachers

11.11 Exercises

Students read Foundations of Python Programming's “Exercises” in CS Room and work through its 4 Python coding exercises.

  • Time: 1 class period

Reading first

Exercises

FolderGradingTests
01Not graded; students check it themselves0
02Not graded; students check it themselves0
03Not graded; students check it themselves0
04Not graded; students check it themselves0