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

Looking for the book? They have it at the Engineer's Bookstore at 748 Marietta St NW. Here is there website: http://www.engrbookstore.com/ - Monica

Hotspots: Slides and CodeTA CornerComments?AnnouncementsFAQStatic Webspace
View this PageEdit this PageUploads to this PageHistory of this PageHomeRecent ChangesSearchHelp Guide

Midterm Exam 2 Review Spring 2006: Compute the grade


def finalGrade(a, b, c):
 grade = ( ( ( ( ( a + b ) * 0.4 ) + ( c * 0.6 ) ) / 140 ) * 100 )
 if grade >= 90:
  return " congratulations you got an A "
 if grade >= 80 and grade < 90:
  return "you got a B"
 if grade >= 70 and grade < 80:
  return "you got C"
 if grade >= 60 and grade < 70:
  return " you got D "
 if grade < 60:
  return "Uh-oh"

You might want to check out how you computed grade Amanda Bennett
Why are you dividing by 140? -poof #10


Here is my version. I checked it on JES, and it seems to work.
def finalGrade(examScore1, examScore2, examScore3):
  a = examScore1&star.2
  b = examScore2&star.2
  c = examScore3&star.6
  finalGrade = a+b+c
  if finalGrade >=90:
    print "Congratulations, you got an A!"
  if finalGrade >=80 and finalGrade < 90:
    print "You got a B."
  if finalGrade >=70 and finalGrade < 80:
    print "You got a C."
  if finalGrade >=60 and finalGrade <70:
    print "You got a D."
  if finalGrade <60:
    print "Uh-oh."


sorry about the asterisks in the above post (&star = asterisk)

The only thing you need to add to that program is a line after "finalGrade = a+b+c" that says "print finalGrade" since the program is supposed to pring the final score and print one of the phrases.

This is what I put:

def finalGrade(exam1,exam2,exam3):
  midterms= (exam1+exam2/2)&star.40
  final= exam3&star.60
  finalscore=midterms+final 
  print finalscore
  if finalscore >=90:
    print "Congatulations, you got an A!"
  if finalscore >=80 and finalscore <90:
    print "You got a B."
  if finalscore >=70 and finalscore <80:
    print "You got a C."
  if finalscore >=60 and finalscore <70:
    print "You got a D."
  if finalscore <60:
    print "Uh-oh."



Does this work with the in range?:
def computeGrade(exam1,exam2,final):
  avg=(exam1+exam2)/2
  percent=avg&star.4
  percent2=final&star.6
  finalgrade=percent+percent2
  if finalgrade >= 90:
    print 'Congratulations, you got an A!'
  if finalgrade in range (80,90):
    print 'You got a B'
  if finalgrade in range (70,80):
    print 'You got a C'
  if finalgrade in range(60,70):
    print 'You got a D'
  if finalgrade <60:
    print 'YOU FAIL'


def finalGrade(exam1,exam2,final):
finalScore=((exam1+exam2)&star0.20 + final&star0.60)
print finalScore
if finalScore>=90:
print "Congratulations, you got an A!"
if finalScore>=80 and finalScore90:
print "You got a B."
if finalScore>=70 and finalScore80:
print "You got a C."
if finalScore>=60 and finalScore70:
print "Welcome to Tech!"
if finalScore60:
print "UGA isn't THAT bad..."



Link to this Page