End-To-End Example: Pay Rate Calculator

Write a program to prompt for inputs of the hourly rate and the hours worked, then output the total pay. Then input the tax rate and output the net pay.

Procedure:

  • write to do list
  • write initial code
  • re-write code to be better

In [5]:
# TODO List:
hourly_rate = float(input("Enter hourly rate: ")) # input hourly rate
hours_worked = float(input("Enter hours worked: ")) # input hours worked
total_pay = hourly_rate * hours_worked # calculate total pay
print("Total Pay: $%.2f" % (total_pay)) # output total pay
tax_rate = float(input("Enter tax rate: ")) # input tax rate
net_pay = (1- tax_rate) * total_pay # calculate net pay
print("Net Pay: $%.2f" % (net_pay)) # output net pay


Enter hourly rate: 10
Enter Hours Worked: 100
Total Pay: $1000.00
Enter Tax Rate: 0.15
Net Pay: $850.00

In [ ]: