Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # JHG
- # 12-07-2011
- # Exercise 2.2
- # Prompt the user for their name and welcomes them.
- name = raw_input('Enter your name: ')
- print 'Hello ' + name
- # JHG
- # 12-07-2011
- # Exercise 2.3
- # Prompt the user for hours and rate per hour and
- # compute the pay.
- hours = raw_input('Enter Hours: ')
- rate = raw_input('Enter Rate: ')
- pay = int(hours) * float(rate)
- print 'Pay: ', round(pay, 2)
- # JHG
- # 12-07-2011
- # Exercise 2.4
- # Determine the value of each expression
- # and type of the value.
- width = 17
- height = 12.0
- value1 = width / 2
- value2 = width / 2.0
- value3 = height / 3
- value4 = 1 + 2 * 5
- print '1. width/2'
- print value1 # 8
- print type(value1) # int
- print
- print '2. width/2.0'
- print value2 # 8.5
- print type(value2) # float
- print
- print '3. height/3'
- print value3 # 4.0
- print type(value3) # float
- print
- print '4. 1 + 2 * 5'
- print value4 # 11
- print type(value4) # int
- # JHG
- # 12-07-2011
- # Exercise 2.5
- # Ask the user for a Celsius temperature,
- # convert it to a Fahrenheit temperature.
- celsius = raw_input('Enter Celsius temperature: ')
- fahrenheit = float(celsius) * 9.0 / 5.0 + 32
- print 'Fahrenheit temperature: ', round(fahrenheit, 2)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement