Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #Going gradually through P2PU Python course.
- #Variables, Expressions and Statements
- #Exercise 2.2
- name_prompt = raw_input('Enter your name: ')
- print 'Hello ' + name_prompt
- #Exercise 2.3
- hours = raw_input("Enter hours: ")
- rate = raw_input("Enter rate: ")
- pay = (float(hours))*(float(rate))
- print pay
- #Exercise 2.4
- width = 17
- height = 12.0
- first = width/2
- #I presume this will result in integer and it will be 8. Checking:
- type(first)
- secnd = width/2.0
- #My guess: result will be 8.5 and type will be float
- type(secnd)
- third = height/3
- #Oops. I don't know. I presume it will be 4 or 4.0, but what type will it be?
- #Checked. Type is float
- type(third)
- fourth = 1 + 2 * 5
- # it'll be 11, type int
- type(fourth)
- #Exercise 2.5
- #Convert Celsius to Fahrenheit
- c = raw_input('Enter temperature in Celsius: ')
- f = int(c) * 1.8 + 32
- print str(c) + " Celsius is " + str(f) + " Fahrenheit"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement