0

I am new to Python and I am having a hard time getting this right.

As the title says, how I can get the equivalent marks based on the percentage results.

print('<-------------------------------------------->')
print('            Grade Evaluation Program          ')
print('<-------------------------------------------->')

last_name = input('Enter Last Name: ')
first_name = input('Enter First Name: ')
middle_initial = input('Enter Middle Initial: ')
section_code = input('Enter Section Code: ')

print('<-------------------------------------------->')
print('                 Input Scores                 ')
print('<-------------------------------------------->')

try:
    quiz_one = float(input('Enter Quiz 1 Score: '))
    quiz_one_totalScore = float(input('Enter Quiz 1 Total Points: '))
    quiz_two = float(input('Enter Quiz 2 Score: '))
    quiz_two_totalScore = float(input('Enter Quiz 2 Total Points: '))

    homework_one = float(input('Enter Homework 1 Score: '))
    homework_one_totalScore = float(input('Enter Homework 1 Total Points: '))
    homework_two = float(input('Enter Homework 2 Score: '))
    homework_two_totalScore = float(input('Enter Homework 2 Total Points: '))

    exam_score = float(input('Enter Exam Score: '))
    exam_totalScore = float(input('Enter Exam Total Points: '))
except:
    print('Please enter a whole number.')
    exit()

print('<-------------------------------------------->')
print('                   Results                    ')
print('<-------------------------------------------->')

firstResult = (((quiz_one + quiz_two) / (quiz_one_totalScore + quiz_two_totalScore)) * 100) * 0.30
secondResult = (((homework_one + homework_two) / (homework_one_totalScore + homework_two_totalScore)) * 100) * 0.20
thirdResult = ((exam_score / exam_totalScore) * 100) * 0.50
overall_grade = format(firstResult + secondResult + thirdResult, ".2f")

print('Student Name: ' + last_name + ', ' + first_name + ' ' + middle_initial + '.')
print('Section Code: ' + section_code)
print('Percentage Grade: ' + str(overall_grade) + '%') 
print('Equivalent Grade: ' ) #DisplayPercentageEquivalentGradeHere

print('<-------------------------------------------->')

I tried other solutions like the if-else statement but it just confused me more. Would really appreciate if you could teach me how.

The equivalent marks for each percentage are:

  • 94-100 = 1
  • 88-93 = 1.25
  • 82-87 = 1.5
  • 76-81 = 1.75
  • 70-75 = 2
  • 64-69 = 2.25
  • 58-63 = 2.5
  • 52-57 = 2.75
  • 50-51 = 3
  • 30-49 = 4
  • 0-29 = 5
rjgrl
  • 61
  • 4

1 Answers1

1

Yes if-statements will do.

if overall_grade >= 94:
    print (1)
elif overall_grade >= 88:
    print (1.25)
elif overall_grade >= 82:
    print (1.5)
...
else:
    print (5)
smac89
  • 39,374
  • 15
  • 132
  • 179