Skip to content

Commit bbf5f8a

Browse files
committed
#functions
1 parent dec3524 commit bbf5f8a

File tree

1 file changed

+25
-7
lines changed

1 file changed

+25
-7
lines changed

ActivitySet#1/problem#05.py

Lines changed: 25 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,30 @@
1-
# Functions
1+
# # # Functions
22

33

4-
def computepay(h, r):
5-
pass # ...
4+
# # def computepay(h, r):
5+
# # pass # ...
6+
7+
8+
# # hrs = float(input("Enter hours? "))
9+
# # rte = float(input("Enter rate per hour? "))
610

11+
# # p = computepay(hrs, rte)
12+
# # print("Pay", p)
713

8-
hrs = float(input("Enter hours? "))
9-
rte = float(input("Enter rate per hour? "))
1014

11-
p = computepay(hrs, rte)
12-
print("Pay", p)
15+
# 4.6 Write a program to prompt the user for hours and rate per hour using input to compute gross pay. Pay should be the normal rate for hours up to 40 and time-and-a-half for the hourly rate for all hours worked above 40 hours. Put the logic to do the computation of pay in a function called computepay() and use the function to do the computation. The function should return a value. Use 45 hours and a rate of 10.50 per hour to test the program (the pay should be 498.75). You should use input to read a string and float() to convert the string to a number. Do not worry about error checking the user input unless you want to - you can assume the user types numbers properly. Do not name your variable sum or use the sum() function.
16+
17+
def computepay(h, r):
18+
if h<40:
19+
return h*r
20+
if h>40:
21+
normal_pay = h*r
22+
extra_pay = (h-40.0)*(0.5*r)
23+
groos_pay = normal_pay+extra_pay
24+
return groos_pay
25+
26+
hrs = input("Enter Hours:")
27+
fhrs = float(hrs)
28+
rate = input("Enter Rate:")
29+
frate = float(rate)
30+
print('Pay',computepay(fhrs,frate))

0 commit comments

Comments
 (0)