6. Input Algorithm Output
“A set of rules to be
followed in problem
solving operations.”
7. Input Algorithm Output
• 2 slices bread
“A set of rules to be
• 1 tbsp peanut butter followed in problem
• 2 tsp strawberry jam solving operations.”
8. Input Algorithm Output
• 2 slices bread
“A set of rules to be
• 1 tbsp peanut butter followed in problem
• 2 tsp strawberry jam solving operations.”
12. """
(C) Gerold Penz)
Python can be simple, too :-)
"""
for quant in range(99, 0, -1):
if quant > 1:
print quant, "bottles of beer on the wall,", quant, "bottles of beer."
if quant > 2:
suffix = str(quant - 1) + " bottles of beer on the wall."
else:
suffix = "1 bottle of beer on the wall."
elif quant == 1:
print "1 bottle of beer on the wall, 1 bottle of beer."
suffix = "no more beer on the wall!"
print "Take one down, pass it around,", suffix
print "--"
13. # (c) Barbara Shaurette
def bottles():
for i in reversed(range(100)):
if i > 0:
b = "bottles"
if i == 1: b = "bottle"
print i, b, "of beer on the wall,",
i, b, "of beer"
print "Take one down, pass it around,",
i-1, "bottles of beer on the wallnr"
bottles()
16. “The taxi algorithm”
• Go to the taxi stand.
• Get in a taxi.
• Give the driver my address.
17. “The call-me
algorithm”
• When your plane arrives, call my cell
phone.
• Meet me outside baggage claim.
18. “The rent-a-car
algorithm”
• Take the shuttle to the rental car place.
• Rent a car.
• Follow the directions to get to my
house.
19. “The bus algorithm”
• Outside baggage claim, catch bus
number 70.
• Transfer to bus 14 on Main Street.
• Get off on Elm street.
• Walk two blocks north to my house.