1. Ask the user the number of hours worked 2. Capture the value of the hours variable from keyboard input 3. Ask the user their hourly pay rate 4. Capture the value of the pay_rate variable from keyboard input 5. Calculate the total earned by: a. 40 hours and under are payed at hourly rate b. Any hours over 40 are payed at 1.5x hourly rate 6. The total pay should be out put as currency 7. You final output should look like this: Your total pay is: SX,xxx.x To test your solution use the following information: Hours: 42 Pay Rate: $10/Hr Total pay should be S430.00
The main objective of the python program is to prompt the user to enter the number of hours. Read the value in the hours variable. Then, prompt to enter the pay rate as input from the keyboard. Read the value of the pay rate in the pay_rate variable.
Then calculate the total pay based on the number of hours with the following formula and then print the total payment value.
Case-i: If hours is less than or equal to 40
Case-iI: If hours are above 40
The main.py python program source code
#main.py
def main():
#Prompt user to enter number of hours as input
hours=int(input("Enter number of hours : "))
#Read pay rate from keyboard
pay_rate=float(input("Enter pay rate,$"))
#Check the condition , hours <=40
if hours<=40:
#calculate the total pay
totalpay=hours*pay_rate
else:
#calculate the total pay over 40 hours
totalpay=40*pay_rate+(hours-40)*pay_rate*1.5
#print the total pay
print("Your total pay is :${:,.2f} ".format(totalpay))
#call main function to start the program
main()
The screenshot of the source code with indentation
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 2 images