Skip to content

Commit a7ec984

Browse files
authored
Create Week6_Assignment_4_6.py
1 parent 7ca122a commit a7ec984

File tree

1 file changed

+28
-0
lines changed

1 file changed

+28
-0
lines changed

Week6_Assignment_4_6.py

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
'''Write a program to prompt the user for hours and rate per hour input to compute gross pay.
2+
Pay should be the normal rate upto 40 hours and time-and-a-half for the hourly rate for all hours worked above 40 hours
3+
Use function.'''
4+
5+
#definr function computepay that will calculate the gross pay
6+
def computepay(h,r):
7+
if h>40:
8+
pay = (40*r)+((h-40.0)*r*1.5)
9+
else:
10+
pay = h*r
11+
12+
return pay
13+
14+
#take inputs
15+
hrs = input('Enter hours: ')
16+
rate = input('Enter hourly pay: ')
17+
18+
#chck if the inputs are correct
19+
try:
20+
vhrs = float(hrs)
21+
vrate = float(rate)
22+
except:
23+
print('Hour and Rate must be numeric values.')
24+
quit()
25+
26+
#return gross pay
27+
gross = computepay(vhrs,vrate)
28+
print(gross)

0 commit comments

Comments
 (0)