#Coco Jones #CIS 122 #Chapter 7 Q1 #Input Validation #(> 0 and < 10,000,000 maybe) hoursWorked = int(raw_input("Enter the number of hours worked between 0 and 40 hours\n")) while hoursWorked < 0 or hoursWorked > 40: hoursWorked = int(raw_input("Sorry your number of hours are invalid. Please try again\n")) payRate = float(raw_input("Enter how much you are paid per hour between $7.50 and $18.25\n")) while payRate < float(7.50) or payRate > float(18.25): print "Sorry your pay is either too low or too high. Please try again" payRate = float(raw_input("Enter how much you are paid per hour\n")) print ("Your gross pay is " + str(float(payRate * hoursWorked)))
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