Year of Python (YOP) – Week Eighteen


Hello Reader!

Today’s post will be short.  The college semester finished this week, so most of my time has been spent grading final exams as well as finishing grading some lab assignments.  However, it wasn’t enough to stop the YOP!

My script this week was one I created to help with determining the final grades for my students.  Like most courses there are different weights to different parts of the course (exams, homework assignments, etc).  In prior years I found a website online that was designed to help teachers/students determine their grades so I just used that.  To be honest, I still used the site this year, mainly because it was getting late into the evening and I wanted to get the grades posted.

But once I had the grades tallied (on a spreadsheet I use to track grades) I decided to write some python code and use it to verify that my calculations were correct.  It also gave me something to post for this week.

The first part of this script is simple, ask for the grades:

midterm_total = raw_input("Enter the Midterm grade: ")
final_total = raw_input("Enter the Final Grade: ")
lab_total = raw_input("Enter the Lab Total Grade: ")
homework_total = raw_input("Enter the Homework Total Grade: ")
participation_total = raw_input("Enter the Participation Grade: ")

(I’m replacing the Participation Grade with something else next year)

Simple right?  Next we just calculate the different weights of the grades we’ve just entered.  For reference, the weighting is as follows:

Mid Term – 20%

Final – 20%

Labs – 30%

Homework – 20%

Participation – 10%

And here’s the code that figures the weight part out:

midterm_calc = float(midterm_total) * 0.2
final_calc = float(final_total) * 0.2
lab_calc = float(lab_total) * 0.3
homework_calc = float(homework_total) * 0.2
participation_calc = float(participation_total) * 0.1

Now two out of the last three years I’ve offered up an extra credit assignment for students to work on.  It’s optional, only work a total of 10 points, so I need to factor that in as well:

extra_credit = raw_input("Enter extra credit score (Enter if none): ")

But I include the option that if there isn’t an extra credit score, we can move on and calculate the final grade either way:

if extra_credit:
    grade = (midterm_calc + final_calc + lab_calc + homework_calc + participation_calc) + int(extra_credit)
    grade = midterm_calc + final_calc + lab_calc + homework_calc + participation_total

And then we wrap up by printing what the grade is…

Until next week!


No Responses Yet to “Year of Python (YOP) – Week Eighteen”

  1. Leave a Comment

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: