Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Exercises from:
- # http://p2pu.org/en/groups/python-programming-101/content/variables-expressionss-and-statements/
- #
- # Task: Variables, expressions, and statements
- # Exercises: 2.2 - 2.5
- #
- # User: ulf_st
- # Date: 29.12.2011
- # Exercise 2.2
- ################
- name = raw_input("Please tell me your name: ")
- print "Hello " + name
- # Exercise 2.3
- ################
- hours = float(raw_input("Enter Hours: "))
- rate = float(raw_input("Enter Rate: "))
- pay = str(rate*hours)
- print "Pay: " + pay
- # Exercise 2.4
- ################
- width = 17
- height = 12.0
- print width/2 # Solution: 8 | Type Integer
- print type(width/2)
- print width/2.0 # Solution: 8.5 | Type float
- print type(width/2.0)
- print height/3 # Solution: 4.0 | Type float
- print type(height/3)
- print 1+2*5 # Solution: 11 | Type Integer
- print type(1+2*5)
- # Exercise 2.5
- ################
- fahr2cel = float(raw_input("Enter Fahrenheit temperature: "))
- celsius = str((fahr2cel - 32) * 5.0 / 9.0)
- print "In Celsius: " + celsius
- cel2fahr = float(raw_input("Enter Celsius temperature: "))
- fahrenheit = str((cel2fahr + 32) / 5.0 * 9.0)
- print "In Celsius: " + fahrenheit
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement