#Josh Roybal #CIS 122 #Chapter 7 Programming Exercise #1 def calculatePay(payRate, hoursWorked): if payRate >= 7.50 and payRate <= 18.25: if hoursWorked >= 0 and hoursWorked <= 40: grossPay = payRate * hoursWorked print('Gross pay is $', grossPay, '. \n') else: print('Invalid number of hours entered. \n') else: print('Invalid pay rate entered. \n') def main(): keepGoing = 1 while keepGoing == 1: payRate = float(input('Please enter the pay rate: ')) hoursWorked = float(input('Please enter the number of hours worked: ')) calculatePay(payRate, hoursWorked) promptChar = input("Would you like to make another calculation? (Y or N): ") if promptChar == 'n' or promptChar == 'N': print("Exiting program...") keepGoing = 0 else: print("Continuing program!") keepGoing = 1 main()
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