Detailed Notes
This episode looks into numeric operators. We have a few examples to help you get comfortable but will see these a lot as the course continues.
Helpful links: https://www.programiz.com/python-programming/operators
Learn more about the overall certification and syllabus here: https://pythoninstitute.org/certification/pcap-certification-associate/pcap-exam-syllabus/
Github repository for code examples: https://github.com/robbroadhead/PythonCertificationSeries
Transcript Text
[Music] well hello and welcome back we are continuing our python series for working our way towards certification and we have uh sort of working our way through the syllabus the next couple items we're going to talk about is we're going to talk about relational operators briefly and assignments and shortcut operators i'm going to focus on the assignments first we have we've sort of done a little bit we've touched on a couple of relationals although i'm going to you know get deeper into that and we'll actually see more of those as we're progressing through future episodes assignments are the shortcuts and assignments are the same one so the first one we've seen is simple assignment which is which is equals so this we can do a equals 3 b equals six and then we're just going to do well [Music] and so when i say b after we do b equals six and so we've assigned that value [Music] and you can see pretty easily as we've seen uh if i can flip over here there this we can see that we assign it to six and it shows it there we and we've seen a lot of it and we can do something more complicated so we could do um so let's make it let's do like it and so we can do something complex so we can as we've done here so we do six plus seven times nine so we'll do that [Music] and we're going to see the same thing here and we're going to see that so it's going to go ahead and set that value for us i don't know what it actually is so is that 6369 okay so here we go so simple assignment we have we've dealt with that enough i think and we will see more of it now let's look at the shortcuts so now let's do leaving that b it's still six up there but if we do b plus equals six then what we're gonna see is oh did i do that right i did not do that right i don't think oh i'm sorry i should probably actually do that so if i do plus equals six i jump back over here so now it's equal to 12. if i do that again [Music] so same thing i'm going to plus equals again we're gonna see now it's 16. because the plus equals is the same as i'll just do this here so same as b equals b plus six so you do a plus sequence takes the thing on the left and basically it's going to add to that uh whatever it is so it's so as it is it's a shortcut so b plus equals six is the same as b equals b plus six so now we're going to see very similarly if we want to do this if we do a minus equals then we're going to roll it back to um oh i should probably print it my mistake just so you now see so we did a plus equals 6 and then we did b equals b minus 6 and so now it's back to 12. and these short cuts work in a couple of different ways so we can also see we can do a multiplier so b times equals now this is going to be a big number but we're going to see here let's just be what 72 i think yeah so we get to 12 b equals b times 6 we get 72 and we can also do do it times equals uh we need to divide it equals [Music] so now we're going to get back to where we were and notice again that because we're doing a dividing it's going to give us uh we're going to go to a double at this point unless we tell it not to which so we can also do let's do our mod so we're gonna do this a little bit easier different because we can do it as so we do percent equals and then let's also do the same thing uh well let's do this first see what number we get to so now uh b divided by six so it doesn't like that did i not do that right oh i'm sorry because that's the this is mod so the remainder is that but if we did it uh let's see so now we just we've converted to remainder so let's change this a little bit let's do this whoops so we don't screw up um we're going to do c equals b and then do that and then press c and then we're also going to do we do the same thing so we can show it a little bit differently so now let's do uh five so now we're gonna divide by five instead of by six and what we'll see here is that uh we come through and so we do uh a mod six which gives us zero now c equals b where b up here is like a 12. and then if we go by oh yes it was 12 divided by 5 we have 10 but then we have a remainder of 2 which we see there so let's go same kind of thing here [Music] as we can do i think that's the next one we can do yep so we can do a divide it here so let's do c equals b because we're going to change this a little bit so we don't blow it up too much and let's do it this way and we'll see what those last two numbers are and so uh we come here and uh so we come in and we go which let me let me change this just so we can see what our number is so we start here uh print b after oh i didn't want to press it that's why i don't want to parent c twice my mistake okay let's go back to this so it's 12 12 divided by 6 is 2. um but also because this and this is the um the dividing by we're not worried about the remainder so we still get 2 because we divide 12 by 6 goes in 6 goes in twice if we divide 12 by 5 then it goes in twice still there so if we were to do um let's say 3 for that second one then we're going to get four and remember it's we're not worried about uh it's just the whole number at that point that comes in even though it gives us a float back we're concerned about the whole number of times that it goes in and this leaves us our last one is that we can do this uh let's do it to the third just because it's equals b print c blah blah blah three there oops that's a three and so now we get oh darn it what did i do there there we go so now if we go back to this last one so we come back and b is equal to 12 and we're doing this so this is to the third power so this is the same as uh which we're going to say this equals 2 b equals b times b times b which is a big number 12 times 12 is 144 12 times 144 obviously i'm guessing is gonna be 1728. so those are shortcuts so we can use that and it is fairly useful to use those on a regular uh basis we also have um some assignment kinds of things that we can do that are similar uh let's see let's go here let's open this oh there we did those are assignments assignments let's change up so let's do d equals one so d equals one [Music] and then so let's uh i do want to say that note that you cannot do what you may be used to she can't do d plus plus because you're going to get that because you may have seen this before especially if you're in a uh c java c sharp that kind of world c plus all those they have a plus plus and a minus minus you may have seen these things before like a plus equals minus equals those do not exist in the python world so i don't know that there's a test question necessarily on that but that's a good one to know now the next one we um actually let's do it this way i just want to do because this is sort of quick we're going to do some comparisons and uh let's see most of these we have see we will see as we go further in but that's what i want to i do want to touch on them so we've got equals equals we've got greater than equals we've got less than equal less than equals we have less than we have greater than and uh those are oh let's see one two three four and we also have not equals so we have not equals we have i'm sorry i'm looking at my list real quick to make sure i've got them all yes we've got equals not equals greater than greater than equals less than less than equals those are our comparisons and so we can see that uh so let's do a equals 1 b equals two c equals three d equals uh let's see uh let's do a plus b and there we go oh and let's do e equals ten we'll just do that just to give us a couple to work with so we can start with something simple like a equals b and and let's do a equals b and uh let's see let's try oh we'll just do oh let's see let's do d equals c so if we do those [Music] and oh actually it doesn't matter uh in some cases it does in equals it does not if you do an equals equals it's just are these two equals so we're gonna see uh here so a is not equal to b because a is one b is two but d equals c is true because d is equal to one plus two which is three c is equal to three so we can also do uh let's see now we if you have a greater there than then it is going to make a difference so if we do if we do a greater than b greater than or equal to b which it is not but if we do a less than equal to b then it is and so we will see a false and a true at the end there we go there and so we can also take uh so let's say oh let's do a couple here so back to that one we did before so we could say if uh c is greater than is somewhere early c greater than equal to d and then also c is greater than equal to uh a well and so if we run those those are both true because we're going to see that because c which is 3 is greater than or equal to d and we know it's already it's equal to it and we also know that it's greater than a and then we can do but now so c greater than equal to d let's take that one again but now let's just say that it's greater than d see what happens there and then let's do c is not equal to a then we're going to see that it's false and then true because here it's not greater than d it's equal to so we're not gonna we're gonna get a false on that and c is not equal to a is true because c is three a is one so those are sort of just getting started on some of the comparisons i think you'll be pretty comfortable with them by the time we go through those the shortcuts are a little less common uh because especially because you can get away without using them you could you can code forever and not ever use a shortcut because it is simply a shortcut now the assignments and the operators you're gonna i don't think you can get any real good logic ever into a program without utilizing those but these are particularly if you're if you've got another language that you've learned when you get into the idea of getting a certification you really want to make sure that you're comfortable with the how that language does it i don't know if you're going to see something you know like if they want to do one of these on the test or something like that that would be potentially like a not equal but uh whether they do or not just know what not equal looks like and we have seen that a little bit in the uh when we talked about some of the boolean expressions and we'll see more of that as we get into some examples i think further down the road because we'll have some things that will be actually putting together some applications and we're getting there pretty close we're gonna actually focus on numbers the next couple and then uh you'll probably start seeing a little bit more of some scripts and stuff like that that'll do it for today i think it's a good time to good point to wrap it up so we'll uh we'll wrap this one up here as always check out the sites uh you can check out the youtube channel and you can see some links and such uh you've always got the uh it includes the link to the github repository so you can see all of these uh code examples out there play around with it yourself uh jump in there and just start getting comfortable with some of these very you know basic concepts of python so that as we get further into it it just feels more comfortable you're building hopefully on top of what we've already covered that being said go out there and have yourself a great day a great week and we will talk to you next time you
Transcript Segments
[Music]
well hello and welcome back
we are continuing our python series for
working our way towards certification
and
we have uh sort of working our way
through the syllabus
the next couple items we're going to
talk about is
we're going to talk about relational
operators briefly
and assignments and shortcut operators
i'm going to focus on the assignments
first we have
we've sort of done a little bit we've
touched on a couple of relationals
although i'm going to
you know get deeper into that and we'll
actually see more of those
as we're progressing through future
episodes
assignments are the shortcuts and
assignments are the same one
so the first one we've seen
is simple assignment which is
which is equals so this we can do
a equals 3 b equals
six
and then we're just going to do well
[Music]
and so when i say b after we do b equals
six and so we've assigned that value
[Music]
and you can see pretty easily as we've
seen uh if i can flip over here
there this we can see that we assign it
to six
and it shows it there we and we've seen
a lot of it and we can do something more
complicated so we could do
um so let's make it
let's do like it and so we can do
something complex so we can as we've
done here so we do six
plus seven times nine so we'll do that
[Music]
and we're going to see the same thing
here and we're going to see that
so it's going to go ahead and set that
value for us
i don't know what it actually is so is
that 6369 okay so here we go
so simple assignment we have we've dealt
with that enough
i think and we will see more of it
now let's look at the shortcuts so now
let's do leaving that b it's still six
up there
but if we do b plus equals six
then what we're gonna see
is
oh did i do that right i did not do that
right i don't think oh
i'm sorry i should probably actually do
that
so if i do plus equals six
i jump back over here so now it's equal
to 12.
if i do that again
[Music]
so same thing i'm going to plus equals
again we're gonna see now it's 16.
because the plus equals is the same as
i'll just do this here so same as
b equals b plus six
so you do a plus sequence takes the
thing on the left
and basically it's going to add to that
uh whatever it is so it's so as it is
it's a shortcut
so b plus equals six is the same as b
equals b
plus six so now we're going to see very
similarly
if we want to do
this
if we do a minus equals then we're going
to roll it back to
um oh i should probably print it
my mistake
just so you now see so we did a plus
equals 6 and then we did b equals b
minus 6 and so now it's back to 12.
and these short cuts work in a couple of
different ways so we can also see we can
do
a multiplier
so b times equals
now this is going to be a big number
but we're going to see here let's just
be what 72 i think
yeah so we get to 12
b equals b times 6 we get 72
and we can also do
do it times equals uh we need to divide
it
equals
[Music]
so now we're going to get back to where
we were
and notice again that because we're
doing a dividing
it's going to give us uh we're going to
go to a double at this point
unless we tell it not to which
so we can also do let's do our mod
so we're gonna do this a little bit
easier different because we can do it as
so we do percent equals
and then let's also do the same thing
uh well let's do this first see what
number we get to
so now uh
b divided by six so it doesn't like that
did i not do that right
oh i'm sorry because that's the this is
mod so the remainder is that
but if we did it
uh let's see so now we just we've
converted to remainder so let's
change this a little bit let's do this
whoops
so we don't screw up
um we're going to do c equals b
and then do that and then press c
and then we're also going to do we do
the same thing so we can show it a
little bit differently
so now let's do uh five
so now we're gonna divide by five
instead of by six and what we'll see
here
is that uh we come through
and so we do uh a mod six
which gives us zero now c equals b
where b up here is like a 12.
and then if we go by oh yes it was 12
divided by 5 we have 10 but then we have
a remainder
of 2 which we see there
so let's go same kind of thing here
[Music]
as we can do i think that's the next one
we can do yep
so we can do a divide it here
so let's do c equals b because we're
going to change this a little bit
so we don't blow it up too much
and let's do it this way and we'll see
what those last two numbers are
and so uh we come here and
uh so we come in and we go which let me
let me change this just so we can
see what our number is
so we start here
uh print b after oh i didn't want to
press it that's why i don't want to
parent c twice my mistake
okay let's go back to this so it's 12 12
divided by
6 is 2.
um but also because this and this is
the um the dividing by we're not worried
about the
remainder so we still get 2 because we
divide 12 by 6
goes in 6 goes in twice if we divide 12
by 5
then it goes in twice still there so if
we were to do
um let's say 3
for that second one then we're going to
get four and remember it's
we're not worried about uh it's just the
whole number at that point that comes in
even though it gives us a float back
we're concerned about the whole number
of times that it goes in
and this leaves us
our last one
is that we can do this uh
let's do it to the third just because
it's equals b print c
blah blah blah three there oops
that's a three and so now we get oh
darn it
what did i do there there we go
so now if we go back to this last one so
we come back
and b is equal to 12 and we're doing
this so this is to the third power so
this is the same as
uh which we're going to say this equals
2
b equals b times b
times b
which is a big number 12 times 12 is 144
12 times 144 obviously i'm guessing is
gonna be 1728.
so those are shortcuts so we can use
that and it is
fairly useful to use those on a regular
uh
basis we also have
um some assignment
kinds of things that we can do that are
similar
uh let's see let's go here
let's open this oh there we did those
are assignments assignments let's change
up
so let's do d equals one
so d equals one
[Music]
and then
so let's uh i do want to say that note
that you cannot do
what you may be used to
she can't do d plus plus
because you're going to get that because
you may have seen this before especially
if you're in a
uh c java c sharp that kind of world c
plus all those they have a plus plus and
a minus minus
you may have seen these things before
like a plus equals minus equals
those do not exist in the python world
so
i don't know that there's a test
question necessarily on that but that's
a good one to know
now the next one we um actually let's do
it this way i just want to do because
this is sort of quick we're going to do
some comparisons
and uh let's see
most of these we have see we will see as
we go further in but that's what i want
to i do want to touch on them so we've
got equals equals we've got
greater than equals we've got less than
equal
less than equals we have less than we
have
greater than
and uh those are oh let's see one two
three four and we also have
not equals so we have not equals
we have i'm sorry i'm looking at my list
real quick to make sure i've got them
all
yes we've got equals not equals greater
than greater than equals less than less
than equals
those are our comparisons and so we can
see
that uh so let's do
a equals 1 b equals two
c equals three d
equals uh let's see
uh let's do a plus b
and there we go
oh and let's do e equals ten we'll just
do that just to give us a couple to work
with
so we can start with
something simple like a equals b
and
and let's do a equals b and
uh let's see
let's try oh we'll just do
oh let's see let's do d
equals c
so if we do those
[Music]
and oh actually it doesn't matter uh in
some cases it does in equals it does not
if you do an equals equals it's just are
these two equals so we're gonna see
uh here so a is not equal to b because
a is one b is two but d equals c
is true because d is equal to one plus
two which is three
c is equal to three so we can also do
uh let's see now we if you have a
greater there than
then it is going to make a difference
so if we do
if we do a greater than b greater than
or equal to b which it is not
but if we do a less than equal to b then
it is
and so we will see a false and a true at
the end there we go there
and so we can also take uh
so let's say oh
let's do a couple here so back to that
one we did before so we could say
if uh c is greater than
is somewhere early c greater than equal
to
d and then also
c is greater than
equal to uh a
well and so if we run those
those are both true because we're going
to see that because c
which is 3 is greater than or equal to
d and we know it's already it's equal to
it and we also know that it's greater
than
a and then we can do
but now so c greater than equal to d
let's take that one again
but now let's just say that it's greater
than d see what happens there
and then let's do c is not equal to a
then we're going to see that it's false
and then true because here
it's not greater than d it's equal to so
we're not gonna we're gonna get a false
on that
and c is not equal to a is true because
c
is three a is one
so those are sort of just getting
started on some of the comparisons i
think
you'll be pretty comfortable with them
by the time we go through those
the shortcuts are a little less common
uh because especially because you can
get away
without using them you could you can
code forever and not
ever use a shortcut because it is simply
a shortcut now the assignments and the
operators
you're gonna i don't think you can get
any real good logic ever into a program
without utilizing those but
these are particularly if you're if
you've
got another language that you've learned
when you get into the idea of
getting a certification you really want
to make sure that you're comfortable
with the
how that language does it i don't know
if you're going to see something
you know like if they want to do one of
these on the test
or something like that that would be
potentially like a not equal
but uh whether they do or not just know
what
not equal looks like and we have seen
that a little bit
in the uh when we talked about some of
the boolean expressions and we'll see
more of that
as we get into some examples i think
further down the road because we'll have
some things that will be
actually putting together some
applications and we're getting there
pretty close we're gonna actually focus
on numbers the next couple
and then uh you'll probably start seeing
a little bit more of some scripts and
stuff like that
that'll do it for today i think it's a
good time to good point to wrap it up
so we'll uh we'll wrap this one up here
as always check out the sites uh you can
check out the youtube channel and you
can see some links and such
uh you've always got the uh it includes
the link to
the github repository so you can see all
of these uh code examples out there
play around with it yourself uh jump in
there and just start getting
comfortable with some of these very you
know
basic concepts of python so that as we
get further into it
it just feels more comfortable you're
building hopefully on top of
what we've already covered that being
said
go out there and have yourself a great
day a great week and we will talk to you
next time
you