Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## ex. 2.2
- ## Write a program that uses raw_input to prompt a user for their name and then welcomes them.
- name = raw_input('What is your name? \n')
- print "Hello ", name
- ## ex. 2.3
- ## Write a program to prompt the user for hours and rate per hour to compute gross pay.
- ## Enter Hours: 35
- ## Enter Rate: 2.75
- ## Pay: 96.25
- hours = raw_input('Enter hours \n')
- while hours.isdigit()==False:
- hours = raw_input('Please enter a number for hours \n')
- rate = 2.75
- pay = float(hours)*rate
- print "Pay ", round(pay,2)
- ## ex. 2.4
- ## Assume that we execute the following assignment statements:
- ## width = 17
- ## height = 12.0
- ## For each of the following expressions, write the value of the expression and the type (of the value of the expression).
- ## 1. width/2
- ## 2. width/2.0
- ## 3. height/3
- ## 4. 1 + 2 * 5
- width = 17
- height = 12.0
- print 'width/2=',width/2
- print 'width/2.0=',width/2.0
- print 'height/3=',height/3
- print '1+2*5=', 1+2*5
- ## ex. 2.5
- ## Write a program which prompts the user for a Celsius temperature, convert the temperature to Fahrenheit and print out the converted temperature.
- tempC=raw_input('Tell me the temperature in Celsius \n')
- while tempC.isdigit()==False:
- tempC=raw_input('The temperature must be a number \n')
- print 'The temperature in Fahrenheit is ', float(tempC)*9/5+32
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement