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 i got another kind
of fun python tutorial for you and we're
going to be looking at um building an
interactive gradebook utility inside of
python and so essentially what this
means is i want to build a tool like a
teacher might find useful in a classroom
where you can do a few things like you
can modify the uh value of each
assignment you can add students and
insert their grades and then you can
actually view grades back so um let's go
ahead and get into it this is going to
assume that you know a little bit of
python so if you're unfamiliar with any
sort of object-oriented programming you
probably do want to check out this
channel for
the intro to python's playlist intro to
python playlist and that'll get you
started but without further ado let's
get going um
essentially because there are a few
different things that you can do in this
function i want to start by actually
figuring out what the user wants to do
so i'm going to call the action
variable and i'm going to set it equal
to something i'll create a function
called initialize that's essentially
going to be
what we run every time we want to do a
new action so basically
inside of initialize
excuse me we're going to gather the
action from the user
and we'll just start by printing out and
saying
welcome to
your grade book
make a
selection okay so we'll just print that
text on the screen
and then let's get the
selection and let's actually set it
equal to an input
from uh the user and we'll say one
modify
weights so um that'll be like modifying
the weight of each grade in your grade
book
like tests quizzes homework and how much
each thing is worth
two will be
add
students and then three will be view
grades okay you could add a whole bunch
of things
to this i'm basically just trying to
show you a format of how to build
an expandable
program so then we'll say four is exit
if you're done with the code and
everything
already but then we're going to get
their selection while we're inside of
this and let's just go ahead and return
the selection
and actually we've written this to where
we want to be an integer and python's
default input is going to grab you a
string so we add the int to it to get
that selection variable as an integer
and then that gets transferred into
action as it's running
and then we'll create our actual
functional loop so basically while
action is not equal to 4 right because 4
means exit then we're going to do
something else so then we're going to
check with some if statements
and see well if the action is equal to 1
what do we say we're going to do we're
going to modify weights so let's go
ahead and create a function
called modify weights but since we're
here let's go ahead and define
everything and that'll tell us exactly
what we need to make as we go through
two will be
add students
and then
three is gonna be
view
grades okay
um but then once action is four they're
exiting so let's just go ahead and tell
them on their way out like print
thanks for
using the
gradebook alrighty and then we'll just
exit code
you don't even need to put the exit it's
the end of your program so it's going to
say process exited but i'm just showing
that that's where it finishes and then
let's go ahead and create those
functions right now and um
modify
weights
and let's just pass it for now
so that we don't get those errors
anymore
and we'll actually flesh out what each
of them do
as we get going here
but this will help us uh create holders
for all the code as we define each thing
and then three was going to be view
grades
yep
okay so we've just created basically
holders to
insert the code for each of these
functions into
modify weights add students view grades
and then an important thing is every
time this finishes uh one of the
functions we need to run that initialize
again because it's going to do a
function once
and then we're going to go ahead and
update the action based on uh whether or
not that was all they wanted to do or if
they want to do something else so it's
important to add that action equals
initialize to every iteration of the
while loop otherwise you're going to be
stuck in an infinite loop if you know
anything about programming infinite
loops are bad okay
so let's go ahead and um start with one
let's just go in order and let's modify
the weights and so you know what i'm
talking about when i say
um like a a waiting um you in a
school you would have um this standard
like format of saying well tests are
equal to
50 of your grade and quizzes are going
to be equal to
30 of your grade and then homework
will be equal to
you got put
in print in
quotations
uh homework is going to be equal to that
last 20 of your grade so it makes the
most sense in my mind to uh put that in
the dictionary there's a few ways you
could do it
but i really think a dictionary where
you associate key uh value pairs um is
the best way to go and that way when we
do modify weights um
we have like a starting table to start
from just a default table
and so we're gonna actually start by
printing out and just saying the current
weighting is
and then let's convert that weights
table to a string and so this is just
letting the user see what the weight
currently is you don't want to keep
something a secret
um and then let's just create a variable
called repeat
because we want them to be able to
modify as many
times as they want
so we'll make repeat and input and we'll
say
would you like to modify these and then
we'll tell them please enter yes or no
um
alrighty and then let's do another while
loop so while
repeat
equals yes and we're gonna ask them
every time they finish modifying
something if they want to do it again so
that and then if they say no we'll make
repeat equal to no and then we'll move
on you could make it a boolean true
false value that's not how i'm doing it
right now
but let's get into it so while repeat is
on
let's pick a a
a weight that we're going to call modify
or a variable that we're going to call
modify and that's going to be an input
where we ask the user to say which item
which item would you like to modify
okay
and then let's put a
let's post base in there
alrighty so that's going to give us the
modify value and then what we're going
to do is we're going to go into our
weights table and look for that key that
they just entered so you would enter in
that input like tests quizzes or
homework
and then what we're going to do
is we're going to update the value to an
integer now but another input and we ask
the user
enter
the new
weight for this
item
okay
and so
let's go ahead and kind of grab these
two lines of code and stick it inside
our while loop as well
so then we'll say the current weighting
is and show them the weights now that
it's been modified
and then ask if you would like to modify
these
again okay and so now we're inside of a
loop that'll just run as many times as
we need it to run
and then we can return from the function
so uh that's a good bit of code but
let's actually start running this just
so we can kind of see the practical side
of why do this
so here we go welcome to your grade book
make a selection and let's say we want
to modify some weights the current
weighting is test 50 quizzes 30 homework
20 and let's say yes we want to modify
them we want to modify the weight of the
tests and make it up to 60.
okay now let's say we also need to
modify because our total is way more
than 100 now
so let's modify homework down to 10.
okay now we can look at and see tests
are 60 quizzes are 30 homework is 10 so
no i'm good i don't need to modify any
more it lets us go back to the grade
book and now the only other thing we
have in place is if i put in a four
it should let me exit and it does so um
right there that's a great start we've
created like a multi-function tool and
we've defined the first function inside
of it this video is almost at 10 minutes
so i'm going to wrap it up right here
but we're going to go ahead and define
add students and view grades and do a
lot of polishing up of this function in
part two so if you found this useful
make sure to check that out as well and
uh be sure to check out all the other
content on the channel we have tons of
tutorials in python and other software
platforms and if you found this or
anything else useful be sure to leave a
like and a subscribe it helps channel
out a ton
and as always good luck with your code
and thanks for watching thanks bye