Hi, in this article lets look in to how to calculate pay rate by asking the user to enter the number of hours worked and then pay per hour.
Write a Program to Prompt The User For Hours And Rate in Python
Lets take two variables hours and pay_rate, ask user to enter both the variable values, convert it in to float. Once we get number of hours worked and rate of pay, take another variable pay and multiply both the floating values and store the result in variable pay.
Print the amount that employee will be paid using print() function.
Code :
hours = float(input("Enter Number of Hours Worked :"))
pay_rate = float(input("Enter Rate of Pay per Hour :"))
pay = hours * pay_rate
print("You will get paid : ", pay)
OUTPUT 1 :
# python main.py
Enter Number of Hours Worked : 8
Enter Rate of Pay per Hour : 10
You will get paid : 80.0
OUTPUT 2 :
# python main.py
Enter Number of Hours Worked : 40
Enter Rate of Pay per Hour : 50
You will get paid : 2000.0
Conclusion : Try to run all the program by yourself and comment down below if you have any issue.
0 Comments