Python Forum
Calculating Grade Average
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Calculating Grade Average
#1
Hey
I'm currently working on a school assignment and I have to program a program to calculate the average of a custom amount of marks of which every single one can count more or less (e.g. one grade counts as a whole mark: 100% and another one only half: 50%). Programing a program that calculates the average of a given amount of custom numbers and the same weighting is easy but as soon as the amount and weighting of the grades varies, I can't keep up with my skills, please teach me :)
Reply
#2
What have you tried? We're not big on writing code for people here, but we would be happy to help you fix your code when you run into problems. When you do run into problems, please post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#3
(Jan-25-2019, 06:19 PM)ichabod801 Wrote: What have you tried? We're not big on writing code for people here, but we would be happy to help you fix your code when you run into problems. When you do run into problems, please post your code in Python tags, and clearly explain the problem you are having, including the full text of any errors.

I can simply show you the calculator without the custom amount of grades nor the weighting of them:
exam_1_grade = input('First Exam Mark: ')
exam_2_grade = input('Second Exam Mark: ')
exam_3_grade = input('Third Exam Mark: ')
summands = float(exam_1_grade) + float(exam_2_grade) + float(exam_3_grade)
result = summands / 3
print(result)
if float(result) >= 3.75:
    print("Well done, your mark is sufficient\n")
else:
    print("Try harder, you can do it\n")
print("Please type yes or no as an answer.")
answer = input("close?: ")
if str(answer) == "yes":
    exit()
elif str(answer) == "no":
    finish = input("Press enter to close")
    if str(finish) == "":
        exit()
(In my country the grade scale goes from 1-6 and a 4 is sufficient, however a 3.75 will be rounded to a 4.)
Reply
#4
As I said, in the text you quoted, please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

To handle the weights, you multiply each grade by it's weight, and then sum all those products together. Then you divide by the sum of the weights, and that gives you the weighted average. Usually, the weights are normalized so that they sum to one. Then you don't need to divide. But I don't think that's a good assumption to make for this program.
Craig "Ichabod" O'Brien - xenomind.com
I wish you happiness.
Recommended Tutorials: BBCode, functions, classes, text adventures
Reply
#5
(Jan-25-2019, 10:46 PM)ichabod801 Wrote: As I said, in the text you quoted, please use python and output tags when posting code and results. I put them in for you this time. Here are instructions for doing it yourself next time.

To handle the weights, you multiply each grade by it's weight, and then sum all those products together. Then you divide by the sum of the weights, and that gives you the weighted average. Usually, the weights are normalized so that they sum to one. Then you don't need to divide. But I don't think that's a good assumption to make for this program.

Thanks a lot man, you solved the weighting problem Heart
Reply
#6
m1=input("Enter the marks:")
m2=input("Enter the marks:")
m3=input("Enter the marks:")
avg=(m1+m2+m3)
print(avg)
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  Simple Method to calculate average and grade ajitnayak1987 8 6,255 Apr-28-2022, 06:26 AM
Last Post: rayansaqer
  Non Grade/School Help - PLEASE gbyrne12 8 3,035 Jun-19-2021, 07:31 PM
Last Post: snippsat
  Student grade program help debug ccm1776 3 5,103 Nov-14-2018, 02:41 AM
Last Post: stullis
  Grade Loop dtweaponx 8 12,345 Oct-17-2017, 02:01 PM
Last Post: buran
  Help? Letter Grade assignment.. zepel 3 4,584 Apr-23-2017, 12:47 PM
Last Post: idontreallywolf

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020