Successfully reported this slideshow.
Upcoming SlideShare
×

# Algorithms are Recipes

3,092 views

Published on

Introduction to what algorithms are, and how to create them for real life

• Full Name
Comment goes here.

Are you sure you want to Yes No

• Be the first to like this

### Algorithms are Recipes

1. 1. Algorithm
2. 2. What is an algorithm?
3. 3. “A set of rules to befollowed in problemsolving operations.”
4. 4. or “A Recipe”
5. 5. Input Algorithm Output
6. 6. Input Algorithm Output “A set of rules to be followed in problem solving operations.”
7. 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. 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.”
9. 9. Input Algorithm Output• 2 slices bread• 1 tbsp peanut butter• 2 tsp strawberry jam
10. 10. Selena & Michelle’s PBJ algorithmHow many steps do you think it will take?
11. 11. There’s more than one way to do it.
12. 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: sufﬁx = str(quant - 1) + " bottles of beer on the wall." else: sufﬁx = "1 bottle of beer on the wall." elif quant == 1: print "1 bottle of beer on the wall, 1 bottle of beer." sufﬁx = "no more beer on the wall!" print "Take one down, pass it around,", sufﬁx print "--"
13. 13. # (c) Barbara Shaurettedef 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()