Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/bin/python
- # Python for Informatics
- # Chapter 2 - Variable, expression and statements
- print 'Python for Informatics - Chapter 2: Variable, expression and statements'
- # Exercise 2.2
- print '\n# Exercise 2.2\n'
- prompt = raw_input('Enter your name: ')
- print 'Hello', prompt
- # Exercise 2.3
- print '\n# Exercise 2.3\n'
- hours = float(raw_input('Enter Hours: '))
- rate = float(raw_input('Enter Rate : '))
- pay = round(hours * rate, 2)
- print 'Pay:', pay
- # Exercise 2.4
- print '\n# Exercise 2.4\n'
- print 'width = 17'
- print 'height = 12.0\n'
- print 'width/2 = 8 , integer'
- print 'width/2.0 = 8.5 , float'
- print 'height/3 = 4.0 , float'
- print '1 + 2 * 5 = 11 , integer'
- # Exercise 2.5
- print '\n# Exercise 2.5\n'
- celsius = float(raw_input('Temperature in Celsius: '))
- fahrenheit = celsius * 1.8 + 32
- print round(celsius,1), 'C =', round(fahrenheit,1), 'F'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement