Change Contents of the Bubble
Welcome to CS1315. Click on the python to add comments.

This page removed for FERPA compliance
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 1 Review Fall 2005: Compute the pay rate


def pay(worked,rate):
pay=(workedrate):
if pay100:
tax=(pay.25)
if 100=pay200:
tax=(pay.30)
if 200=pay300:
tax=(pay.35)
if 300=pay400:
tax=(pay.45)
if pay>=400:
tax=(pay.50)
netpay=(paytax)
print pay
print netpay





def pay(hours,rate):
gross = hours rate
if gross 100:
tax = .25 gross
if gross >= 100 and gross 200:
tax = .30 gross
if gross >= 200 and gross 300:
tax = .35 gross
if gross >= 300 and gross 400:
tax = .45 gross
if gross >= 400:
tax = .50 gross
print gross
print (gross - tax)

why doesn't this work?



def pay(hours,rate):
gross = hours rate
if gross 100:
tax = .25 gross
if gross >= 100 and gross 200:
tax = .30 gross
if gross >= 200 and gross 300:
tax = .35 gross
if gross >= 300 and gross 400:
tax = .45 gross
if gross >= 400:
tax = .50 gross
print gross
print (gross - tax)

when you want to print out something, how do you know wether you need to put quotes around it? REMOVEDke in previous examples when you want your program to print out "that is a little dark", you need to put quotes around it, then do you need to put quotes around print "netpay,grosspay" or is print netpay,grosspay alright?

When you put quotes around something, it becomes a literal string. If you did print netpay,grosspay then you would see the values for netpay and grosspay. If you did print "netpay,grosspay" then you would see the actual words "netpay" and "grosspay" appear. -Student1680

def pay(hours, rate):
  gross = hours *rate
  if gross  100:
    tax = .25* gross
  if gross >= 100 and gross < 200:
    tax = .30 * grpss
  if gross >= 200 and gross  300:
    tax = .35* gross
  if gross >= 300 and gross< 400:
    tax = .45 * gross
  if gross >= 400:
    tax = .50* gross
  print gross
  print (gross - tax)


I do not know why the JES keep saying it has a syntax error in line 3

im not a TA, but I think that it should be - if gross <100: just a suggestion :)
You should be. -Student1680

Can we print strings? REMOVEDke for the last command when you are supposed to print the gross pay and the net pay can you just have one step that says
'print(gross,netpay)'
assuming you defined netpay as '=gross-tax'?

Yes, but the correct syntax is print gross, netpay if you want to do it that way. -Student1680

def pay(num,rate):
  gross=num*rate
  if gross < 100:
    tx=.25
  if 100 <=gross <200:
    tx=.30
  if 200<=gross<300:
    tx=.35
  if 300<=gross<400:
    tx=.45  
  if 400<=gross:
    tx=.5
  txamt=tx*gross
  net=gross-txamt
  print gross
  print net
   

seems to work

def pay(hrs,rate):
gp=hrsrate
if gp100:
net=gp.75
if gp>=100 and gp200:
net=gp.7
if gp>=200 and gp300:
net=gp.65
if gp>=300 and gp400:
net=gp.55
if gp==400 or gp>400:
net=gp.5
print gp
print net

def pay(hours, rate):
  gpay = (hours * rate)
  print(gpay)
  if gpay <100:
    print (gpay - (gpay*.25))
  if gpay >=100 and gpay <200:
    print (gpay - (gpay*.30))
  if gpay >=200 and gpay <300:
    print (gpay - (gpay*.35))
  if gpay >=300 and gpay <400:
    print (gpay - (gpay*.45))
  if gpay >=400:
    print (gpay - (gpay*.50))


is this okay?



Link to this Page