#exercise 2.2 """prompt for user name and welcomes them with "hello" + name""" name = raw_input("Please enter your name here: ") print name print "Hello", name #Exercise 2.3 """takes raw input for hours and rate and returns gross pay""" hours = raw_input("Please enter your hours here: ") print hours rate = raw_input("Please enter your pay rate here: ") print rate int_hours = float(hours) int_rate = float(rate) gross_pay = int_hours * int_rate print "Your gross pay is ", gross_pay #Exercise 2.4 """given values and do calculations""" width = 17 height = 12.0 prob1 = width / 2 print prob1 prob2 = width / 2.0 print prob2 prob3 = height / 3 print prob3 prob4 = 1 + 2 * 5 print prob4 #Exercise 2.5 """give prompt for Celsius temp and convert to Fahrenheit""" temp_c = raw_input("Enter temperature in degrees Celsius: ") temp_c_float = float(temp_c) print temp_c_float temp_f = (9.0 / 5.0) * temp_c_float + 32 print temp_f
Run
Reset
Share
Import
Link
Embed
Language▼
English
中文
Python Fiddle
Python Cloud IDE
Follow @python_fiddle
Browser Version Not Supported
Due to Python Fiddle's reliance on advanced JavaScript techniques, older browsers might have problems running it correctly. Please download the latest version of your favourite browser.
Chrome 10+
Firefox 4+
Safari 5+
IE 10+
Let me try anyway!
url:
Go
Python Snippet
Stackoverflow Question