Exercise 1 – Write a program that give the employee
1.5 times the hourly rate for hours worked above 40 hours.
hours = raw_input("Enter hours: ")
payrate = raw_input("Enter rate: ")
h=float(hours)
br=float(payrate)
if h>40:
extra = h-40
base = h-extra
sallary = (base*br)+(extra*br*1.5)
else:
extra = 0
base=0
sallary = h*br
print "Pay: " + str(sallary)
Exercise
2 – Rewrite your pay program using try and except so that your program handles
non-numeric input gracefully by printing a message and exiting the program.
hours = raw_input("Enter hours: ")
payrate = raw_input("Enter rate: ")
try:
h=float(hours)
br=float(payrate)
if h>40:
extra = h-40
base = h-extra
sallary = (base*br)+(extra*br*1.5)
print "Pay: " + str(sallary)
else:
extra = 0
base=0
sallary = h*br
print "Pay: " + str(sallary)
except:
print 'Error, please enter numeric input'
Exercise
3 – Write a program to prompt for a score between 0.0 and 1.0. If the score is
out of range print an error. If the score between 0.0 and 1.0, print a grade
using the following table:
uservalue=raw_input("Enter score: ")
try:
x = float(uservalue)
if x<0 or x>1.0:
print "Bad score"
else:
if x<=1.0 and x>=0.9:
print "A"
elif x<=0.89 and x>= 0.8:
print "B"
elif x<=0.79 and x>= 0.7:
print "C"
elif x<=0.69 and x>= 0.6:
print "D"
elif x<0.6:
print "F"
else:
print "Bad score"
except:
print "Bad score"
Casinos with slots, casino games - Online Casinos
OdgovoriIzbrišiA free play no 메리트 카지노 가입 쿠폰 deposit bonus for titanium earrings Slots · Casino Player Rewards: 더킹 카지노 No 샌즈 Deposit Required · No deposit Required · All 도레미시디 출장샵 Slots & Table Games · Online Casino