153k views
13 votes
In python:

Write a program that asks the user for the number of hours worked this week and the hourly rate of pay. The program is to calculate the gross pay. If the number of hours worked is greater than 35, the extra hours are paid at 1.5 times the rate. The program should display an error message if the number of hours worked is not in the range 0 to 70

User Ghazala
by
7.3k points

1 Answer

11 votes

Answer:

The code is shown below:

Step-by-step explanation:

Consider the provided information.

The required code is shown below:

hrs = input("Enter the number of hours worked this week: ")

h = float(hrs)

if h<0:

print("Error")

elif h>70:

print("Error")

else:

xx= input("Enter the hourly rate pay: ")

x=float(xx)

if h<= 35:

print(h * x)

elif h > 35:

print(35* x + (h-35)*1.5*x)

For better understanding refer to the image shown below.

In python: Write a program that asks the user for the number of hours worked this-example-1
User Renato Heeb
by
8.5k points