Learn to build an awesome multi use, multi purpose application in python for grade book score keeping, student tracking and grade displays. This app can be modified endlessly and additional functionality is just waiting to be implemented!
This video displays a wide variety of skills needed to advance as a python programmer, especially for beginners just getting familiar with the platform! This series shows for and while loops, logical if statements, nested functions, different variable types and more!!!
If you like the content from this page please like and subscribe to the channel to see lots more like this! Thanks so much for supporting the page and good luck coding! https://www.youtube.com/channel/UCV5Ab39YnXvTZ6Grar9URxQ
what's going on you guys welcome back to
the channel and today uh we'll be
looking at part two of our python um
building out a gradebook utility
function that we started yesterday so if
you take a look at what we've built
already we built a utility that says
welcome to your gradebook and gives you
these four selections of things you can
do and as we built it out um already you
can modify the weighting of your
assignments and you can change like
tests up to 60
and then you can change homework
down to 10
and then you can say no i'm good and
then you know exit
so what we haven't done yet is we
haven't added the actual tool to add
students into the grade book or view
their grades
so we're going to take a look at that
and if you didn't check out video part
one and you're just here for the
concepts in this video that's cool but
we are going to be starting from a fair
bit of code so i recommend you check
that out first if you're unfamiliar with
python or object-oriented programming in
general this is going to be kind of a
rough place to dive in so definitely
consider checking out some of those
tutorial series on the channel as well
but with no further ado let's get into
it so if they select two in the initial
startup area where they're saying they
want to add students to their grade book
then what i want is another dictionary
that all calls students just like we did
for the waiting where we're actually
going to keep track of our students and
their grades
so let's make one called pete
and let's say on tests he got a 90
on quizzes he got an 80 and homework
he's done 80 he's done most of his
homework and then let's go ahead and add
another student named george who
uh he did great on his tests 100 but
then he kind of got lazy on quizzes and
he doesn't really do his homework so um
let's just start with those two students
that should work
and let's uh let's get right into it so
um the reason i did that is we're going
to be adding students to the list we
could start with it totally blank but
once i start running through it it'll be
kind of nice to have a variety of
students in there
and let's just go ahead and start
getting some information from the user
so you want to add a student so it makes
sense that the first thing we would do
is get an input where we say enter the
student's
name right and if you want a parenthesis
or if you want a single quote that
doesn't end your string you have to use
a backslash
so enter the student's name and then
let's get three more variables which i'm
going to call test score
quiz
score
and we will say homework
score
okay and what we're gonna do is we're
gonna grab this
same input
and the only thing that we really need
to change fundamentally is these all
need to be integers
because we want to use them to actually
calculate a grade in the next function
so we want to grab these in as numbers
you could make them floats
if it's possible to get a decimal
score on your assignment you might want
to make those floats but then we'll say
enter the students
test score
and we will tell them it should be 0 to
100 so it's going to be percentage based
and let's go ahead and grab this
and we will say
now enter their
quiz score and then let's do that again
but this time obviously
homework score alrighty so we've just
grabbed a whole bunch of data but we
haven't done anything with it yet so
what um we want to do let's go ahead and
put all three of those scores into one
list um
into one comma separated values
and
let's just put them make sure order is
very important with these because you'll
be looking them up later by index so you
need to make sure you go tests quizzes
um homework if that's how you defined it
in your list but we're we're setting it
up to look
like a value that can get inserted into
that dictionary that we created in the
same format so we create this grades
variable and then to actually insert it
into our students dictionary all we have
to do is say students
and then
student name
and then so what we just said is
inside the dictionary of students
there's got to be this student name
value and then um and then insert as the
value for that student insert this
grades value so this would be how you
would update it if you needed to modify
an existing student or how you would add
a new entry to the dictionary so this
works for either
and then let's just print out uh so that
we can see that our our code actually
worked and say current student
table is
and then let's just show them a string
vary a string conversion of the students
table so now every time you add a
student you should
see the student
shouldn't see the student show up in
your student table with all the others
okay so
let's go ahead and run that one before
we move on too much and let's say add
students
and let's add jack and he didn't do
great on his tests he's okay on quizzes
and he didn't do too much of his
homework
all right well you can see we have pete
george and jack all in
the selection table so that's pretty
cool let's go ahead and exit one thing
that kind of bugs me we're just going to
do it because it's a stylistic thing
when you enter a value here i'd prefer
to have a space there so i'm not typing
right up on the words
just a little thing that i noticed and
so all right the last thing we need to
do to this um
to this program for it to be kind of
fully working as we've defined it is add
a method where you actually are going to
view the grades so what we need to do
it's pretty much going to be like adding
a student but in reverse now you're
going to give us a student name again
it'll be an input
and again we're going to say enter the
students
name
whose
grade you want to view
okay so now we're asking them okay
you've got this student in your class go
ahead and
go ahead and give us their name and then
what we're going to do from there
is we are going to make a grades
variable just like we defined before and
this time it's going we're going to
assume it already exists inside of our
students table
underneath the key for that student's
name so we pull that
grades out and then very similarly to
what we did before we're going to have a
test score
and that's going to be
let me spell it right
test score and that's going to be grades
at position 0 and then you're going to
have quiz score
and that's going to be grades at
position 1 and then you're going to have
homework score and that'll be at
position two so
um
if you're unfamiliar with why we start
from zero and not one that's just pretty
standard programming uh computers don't
start counting from one they start
counting from zero so the first entry in
that little grades um list that's on the
value of our dictionary for students
is it starts at zero it doesn't start
one so that's why we do it that way but
then what we're actually going to do so
here we'll see the culmination of the
students grades and the weight coming
into play so what we've got to do now is
we have to actually calculate the grade
and the grade is going to be equal to
the
um weight
of
tests
right so it was that ver value 0 to 100
divided by a hundred and then multiplied
by this will actually look a little
better if we multiply it by our test
score
and then divide that by a hundred and
then what we're going to do is we're
going to add to that the same thing
for
and we're going to put this one on a new
line
plus
there we go
um
and i think that's what you need for the
new line there you go
okay and so what we're going to do is do
uh the weight of the tests times the
test score plus the weight of your
quizzes times the quiz score
and then we will add into that the
weight of your homework
times your homework score
and uh that's that's essentially how
your grade is calculated in school so
this is a pretty straightforward
function if you have any specific
questions on it go ahead and ask them in
the comments i can explain it a little
better
if you need if you need it
but then let's go ahead and print
and actually display the grade because
that's the point here so we will say
print out and what do we want to print
we'll print string
of student name
and then let's add some text
is
currently
getting a
and then let's add grade but that's
going to be a float so we have to
convert it to a string to display it
and then let's add some more text and
just say in your class
okay and so that should be all we need
to do to view
a student's grade
and let's go ahead and test that guy
somehow i added a closed dictionary all
right let's go and test that that
should let us view some grades so let's
view grades who do we have in there
already we have pete he's getting an 85.
okay so we can assume that's pretty
close but why don't we actually add a
student
um
and we'll name her
uh
isabel and she's getting a 90 in tests
but she missed all of the quizzes and
she missed all of the homework okay
so you can see here 90 80 80 made a lot
of sense for pete um getting an 85
overall with the waiting but now if we
view
isabelle's grade
she's getting a 45 because she didn't do
quizzes or homework well let's say that
she did that because the tests are
actually worth a lot more than 50 so
let's modify tests and say tests are
actually 80 of the grade
and quizzes
are
only 10
and homework is only 10.
well now
so we're good with that table now if we
view isabelle's grades
she's getting a 72 in the class so you
can see right there you can add um
students with this tool you can view
their grade you can change weighting and
then see how that affects their grade so
this program really didn't take us too
long to make and it can do a lot of
useful things so
this teaches a great a bunch of great
python skills even if you're not
necessarily going to use it to create a
gradebook utility it's just great
practice so hopefully you found this
useful if you have any comments on what
you saw today or want to see something
specific in the future let me know about
in the comments under this video if you
found this or anything else on the
channel useful i really appreciate a
liking to subscribe it helps the channel
out a ton as i'm getting started here
and as always good luck with your code
and thanks for watching thanks bye