1
1
Aaron Stevens
18 March 2009
CS101 Lecture 21: Writing Simple Programs:
Algorithms, The Software Development Process Python Names, Expressions, Input, and Output
2
Overview/Questions What is an algorithm? How do we go about - - PDF document
CS101 Lecture 21: Writing Simple Programs: Algorithms, The Software Development Process Python Names, Expressions, Input, and Output Aaron Stevens 18 March 2009 1 Overview/Questions What is an algorithm? How do we go about writing a
1
Algorithms, The Software Development Process Python Names, Expressions, Input, and Output
2
3
4
½ cup vodka ½ cup Kahlua ½ cup Bailey’s Irish Cream ¼ cup Hershey’s chocolate syrup 1 blender full of ice
Fill blender with ice. Pours other ingredients onto ice. Blend until smooth consistency. Pour into glasses and enjoy.
5
If not all ingredients are present Go to store and buy missing ingredients Fill blender with ice Pour other ingredients into the blender While (not smooth) Turn on blender Wait 10 seconds Turn off blender Test consistency with wooden spoon Pour into glasses and serve
6
7
8
9
10
11
12
13
# currencyconversion.py # A program to convert a price in pesos to dollars.
14
# The word ‘print’ is a Python keyword print “Hello, world!”
15
16
17
18
x pesos dollars dollarsAndCents dollars_and_cents main
9x print
19
input("Enter a price in pesos: ") 7.0 / 100.0 * pesos dollars
20
21
22
23
24
NOTE: input evaluates the input as an expression, whereas raw_input does not. For text input, you will want to use raw_input instead.
25
26
27
28