📺 Develpreneur YouTube Episode

Video + transcript

Python Certification Training - Numeric Operators

2021-06-22 •Youtube

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
0.96

[Music]

26.32

well hello and welcome back

27.76

we are continuing our python series for

30.88

working our way towards certification

33.52

and

34.079

we have uh sort of working our way

36.239

through the syllabus

37.36

the next couple items we're going to

38.559

talk about is

40.399

we're going to talk about relational

41.68

operators briefly

43.52

and assignments and shortcut operators

47.28

i'm going to focus on the assignments

49.2

first we have

50.719

we've sort of done a little bit we've

53.28

touched on a couple of relationals

54.719

although i'm going to

55.6

you know get deeper into that and we'll

58.079

actually see more of those

59.68

as we're progressing through future

62.32

episodes

63.199

assignments are the shortcuts and

64.879

assignments are the same one

66.56

so the first one we've seen

71.52

is simple assignment which is

78.24

which is equals so this we can do

81.92

a equals 3 b equals

85.759

six

89.119

and then we're just going to do well

91.13

[Music]

97.759

and so when i say b after we do b equals

100.079

six and so we've assigned that value

102.16

[Music]

104.96

and you can see pretty easily as we've

106.799

seen uh if i can flip over here

110.479

there this we can see that we assign it

113.52

to six

114.32

and it shows it there we and we've seen

117.119

a lot of it and we can do something more

118.32

complicated so we could do

121.04

um so let's make it

128

let's do like it and so we can do

129.36

something complex so we can as we've

130.8

done here so we do six

132.56

plus seven times nine so we'll do that

139.58

[Music]

141.28

and we're going to see the same thing

142.959

here and we're going to see that

145.28

so it's going to go ahead and set that

148.8

value for us

149.92

i don't know what it actually is so is

151.2

that 6369 okay so here we go

153.76

so simple assignment we have we've dealt

156.879

with that enough

157.68

i think and we will see more of it

160.8

now let's look at the shortcuts so now

166.48

let's do leaving that b it's still six

169.44

up there

170.239

but if we do b plus equals six

177.519

then what we're gonna see

182.84

is

185.44

oh did i do that right i did not do that

187.2

right i don't think oh

188.959

i'm sorry i should probably actually do

191.84

that

192.56

so if i do plus equals six

196

i jump back over here so now it's equal

199.599

to 12.

201.04

if i do that again

206.11

[Music]

208.879

so same thing i'm going to plus equals

210.239

again we're gonna see now it's 16.

212.64

because the plus equals is the same as

217.519

i'll just do this here so same as

222.48

b equals b plus six

226

so you do a plus sequence takes the

228.72

thing on the left

229.599

and basically it's going to add to that

232.879

uh whatever it is so it's so as it is

235.2

it's a shortcut

236.239

so b plus equals six is the same as b

238.56

equals b

239.28

plus six so now we're going to see very

241.92

similarly

245.68

if we want to do

248.959

this

253.36

if we do a minus equals then we're going

255.04

to roll it back to

258.56

um oh i should probably print it

262.24

my mistake

266.32

just so you now see so we did a plus

267.919

equals 6 and then we did b equals b

270

minus 6 and so now it's back to 12.

273.84

and these short cuts work in a couple of

276.88

different ways so we can also see we can

279.199

do

279.68

a multiplier

283.68

so b times equals

288.72

now this is going to be a big number

292.4

but we're going to see here let's just

294.56

be what 72 i think

296.4

yeah so we get to 12

299.6

b equals b times 6 we get 72

302.88

and we can also do

309.52

do it times equals uh we need to divide

312.4

it

312.72

equals

315.22

[Music]

318.639

so now we're going to get back to where

320.639

we were

322.639

and notice again that because we're

325.28

doing a dividing

326.639

it's going to give us uh we're going to

328.96

go to a double at this point

331.28

unless we tell it not to which

335.039

so we can also do let's do our mod

341.68

so we're gonna do this a little bit

342.8

easier different because we can do it as

346

so we do percent equals

353.68

and then let's also do the same thing

356.88

uh well let's do this first see what

358.479

number we get to

360.4

so now uh

363.6

b divided by six so it doesn't like that

366.479

did i not do that right

368.72

oh i'm sorry because that's the this is

370.24

mod so the remainder is that

372.639

but if we did it

376.24

uh let's see so now we just we've

378.96

converted to remainder so let's

380.72

change this a little bit let's do this

383.28

whoops

386.08

so we don't screw up

389.12

um we're going to do c equals b

393.6

and then do that and then press c

397.52

and then we're also going to do we do

400

the same thing so we can show it a

401.36

little bit differently

403.199

so now let's do uh five

406.4

so now we're gonna divide by five

408

instead of by six and what we'll see

409.68

here

411.52

is that uh we come through

415.039

and so we do uh a mod six

419.36

which gives us zero now c equals b

422.88

where b up here is like a 12.

428.16

and then if we go by oh yes it was 12

431.199

divided by 5 we have 10 but then we have

433.68

a remainder

434.4

of 2 which we see there

437.52

so let's go same kind of thing here

443.14

[Music]

446.479

as we can do i think that's the next one

447.919

we can do yep

449.759

so we can do a divide it here

456.56

so let's do c equals b because we're

458.4

going to change this a little bit

460.16

so we don't blow it up too much

464.8

and let's do it this way and we'll see

466.4

what those last two numbers are

470.479

and so uh we come here and

475.28

uh so we come in and we go which let me

478.08

let me change this just so we can

481.84

see what our number is

489.199

so we start here

495.039

uh print b after oh i didn't want to

498.639

press it that's why i don't want to

499.84

parent c twice my mistake

501.52

okay let's go back to this so it's 12 12

504.479

divided by

505.199

6 is 2.

509.039

um but also because this and this is

512.08

the um the dividing by we're not worried

515.36

about the

517.2

remainder so we still get 2 because we

520

divide 12 by 6

521.12

goes in 6 goes in twice if we divide 12

523.44

by 5

524.959

then it goes in twice still there so if

527.2

we were to do

528.16

um let's say 3

531.519

for that second one then we're going to

532.88

get four and remember it's

535.279

we're not worried about uh it's just the

537.12

whole number at that point that comes in

538.72

even though it gives us a float back

540.56

we're concerned about the whole number

542.88

of times that it goes in

545.519

and this leaves us

550.64

our last one

555.92

is that we can do this uh

559.2

let's do it to the third just because

564.08

it's equals b print c

567.76

blah blah blah three there oops

571.519

that's a three and so now we get oh

575.12

darn it

579.44

what did i do there there we go

582.959

so now if we go back to this last one so

584.8

we come back

586.8

and b is equal to 12 and we're doing

590.399

this so this is to the third power so

592.16

this is the same as

595.12

uh which we're going to say this equals

598

2

599.2

b equals b times b

602.399

times b

611.2

which is a big number 12 times 12 is 144

614.88

12 times 144 obviously i'm guessing is

617.68

gonna be 1728.

620.399

so those are shortcuts so we can use

622.24

that and it is

623.519

fairly useful to use those on a regular

626

uh

626.56

basis we also have

631.12

um some assignment

634.16

kinds of things that we can do that are

636.079

similar

638.399

uh let's see let's go here

642.64

let's open this oh there we did those

644.72

are assignments assignments let's change

646.32

up

651.519

so let's do d equals one

657.839

so d equals one

661.16

[Music]

662.399

and then

668.72

so let's uh i do want to say that note

671.92

that you cannot do

674.079

what you may be used to

677.12

she can't do d plus plus

680.56

because you're going to get that because

682.72

you may have seen this before especially

684

if you're in a

684.8

uh c java c sharp that kind of world c

688

plus all those they have a plus plus and

689.68

a minus minus

691.04

you may have seen these things before

692.48

like a plus equals minus equals

694.72

those do not exist in the python world

697.6

so

698.88

i don't know that there's a test

699.92

question necessarily on that but that's

701.68

a good one to know

703.6

now the next one we um actually let's do

706.079

it this way i just want to do because

707.519

this is sort of quick we're going to do

709.12

some comparisons

719.92

and uh let's see

724.8

most of these we have see we will see as

727.36

we go further in but that's what i want

728.639

to i do want to touch on them so we've

730

got equals equals we've got

733.12

greater than equals we've got less than

735.76

equal

737.12

less than equals we have less than we

740

have

740.639

greater than

744.079

and uh those are oh let's see one two

746.72

three four and we also have

748.24

not equals so we have not equals

752.32

we have i'm sorry i'm looking at my list

755.2

real quick to make sure i've got them

756.399

all

756.639

yes we've got equals not equals greater

758.24

than greater than equals less than less

759.92

than equals

760.639

those are our comparisons and so we can

764

see

764.56

that uh so let's do

769.76

a equals 1 b equals two

775.36

c equals three d

778.8

equals uh let's see

782.399

uh let's do a plus b

786.72

and there we go

789.839

oh and let's do e equals ten we'll just

792.639

do that just to give us a couple to work

794.24

with

796.079

so we can start with

799.519

something simple like a equals b

804.959

and

808.88

and let's do a equals b and

813.04

uh let's see

818.24

let's try oh we'll just do

821.519

oh let's see let's do d

825.12

equals c

828.639

so if we do those

834.34

[Music]

839.04

and oh actually it doesn't matter uh in

842.079

some cases it does in equals it does not

844.72

if you do an equals equals it's just are

846.079

these two equals so we're gonna see

849.519

uh here so a is not equal to b because

853.68

a is one b is two but d equals c

857.36

is true because d is equal to one plus

860

two which is three

860.959

c is equal to three so we can also do

865.92

uh let's see now we if you have a

867.839

greater there than

870.56

then it is going to make a difference

874.959

so if we do

880.079

if we do a greater than b greater than

882.72

or equal to b which it is not

884.8

but if we do a less than equal to b then

887.36

it is

888.24

and so we will see a false and a true at

889.92

the end there we go there

894

and so we can also take uh

897.279

so let's say oh

902

let's do a couple here so back to that

904

one we did before so we could say

906.32

if uh c is greater than

909.839

is somewhere early c greater than equal

912.639

to

913.279

d and then also

917.199

c is greater than

921.04

equal to uh a

927.44

well and so if we run those

932.399

those are both true because we're going

934.32

to see that because c

935.68

which is 3 is greater than or equal to

938.88

d and we know it's already it's equal to

940.88

it and we also know that it's greater

943.12

than

943.92

a and then we can do

950.8

but now so c greater than equal to d

952.959

let's take that one again

954.56

but now let's just say that it's greater

956.16

than d see what happens there

958.48

and then let's do c is not equal to a

965.92

then we're going to see that it's false

968.079

and then true because here

969.92

it's not greater than d it's equal to so

972.959

we're not gonna we're gonna get a false

974.24

on that

975.199

and c is not equal to a is true because

978.48

c

978.88

is three a is one

982.56

so those are sort of just getting

985.279

started on some of the comparisons i

987.199

think

987.759

you'll be pretty comfortable with them

989.199

by the time we go through those

991.199

the shortcuts are a little less common

994.72

uh because especially because you can

997.36

get away

998.079

without using them you could you can

999.92

code forever and not

1001.759

ever use a shortcut because it is simply

1005.279

a shortcut now the assignments and the

1008.079

operators

1009.199

you're gonna i don't think you can get

1010.72

any real good logic ever into a program

1013.36

without utilizing those but

1016.48

these are particularly if you're if

1019.199

you've

1019.68

got another language that you've learned

1022.16

when you get into the idea of

1023.759

getting a certification you really want

1026.079

to make sure that you're comfortable

1027.28

with the

1028.319

how that language does it i don't know

1030.4

if you're going to see something

1031.76

you know like if they want to do one of

1034.72

these on the test

1036.319

or something like that that would be

1037.919

potentially like a not equal

1040.319

but uh whether they do or not just know

1042.959

what

1043.6

not equal looks like and we have seen

1047.039

that a little bit

1047.76

in the uh when we talked about some of

1050.64

the boolean expressions and we'll see

1052.48

more of that

1053.039

as we get into some examples i think

1054.559

further down the road because we'll have

1055.84

some things that will be

1057.84

actually putting together some

1059.44

applications and we're getting there

1061.76

pretty close we're gonna actually focus

1064.64

on numbers the next couple

1065.84

and then uh you'll probably start seeing

1068.16

a little bit more of some scripts and

1069.679

stuff like that

1071.36

that'll do it for today i think it's a

1072.48

good time to good point to wrap it up

1075.12

so we'll uh we'll wrap this one up here

1078.4

as always check out the sites uh you can

1080.16

check out the youtube channel and you

1081.679

can see some links and such

1083.039

uh you've always got the uh it includes

1085.28

the link to

1086.559

the github repository so you can see all

1088.48

of these uh code examples out there

1090.88

play around with it yourself uh jump in

1093.12

there and just start getting

1094.32

comfortable with some of these very you

1097.12

know

1097.6

basic concepts of python so that as we

1099.84

get further into it

1101.76

it just feels more comfortable you're

1103.28

building hopefully on top of

1105.12

what we've already covered that being

1107.679

said

1108.72

go out there and have yourself a great

1110

day a great week and we will talk to you

1113.28

next time

1130.559

you