assignment 5.2 python for everybody code example
Example 1: assignment 4.6 python for everybody
def computepay(h,r):
if h > 40:
pa = 40 * r + (h-40)*1.5*r
else:
pa = h * r
return pa
hrs = input("Enter Hours:")
h = float(hrs)
rate = input("Enter Rate")
r = float(rate)
p = computepay(h,r)
print("Pay",p)
Example 2: python for everybody chapter 5.2 assignment
num = 0
largest = -1
smallest = None
while True:
num = input("Enter a number: ")
if num == "done" :
break
try :
numb = int(num)
except :
print('Invalid input')
if smallest is None :
smallest = numb
elif numb < smallest :
smallest = numb
elif numb > largest :
largest = numb
print("Maximum is", largest)
print("Minimum is", smallest)