Python 3 Programming Tutorial: Variables

Sharing buttons:

hello everybody and welcome to my

variables in Python 3 tutorial video in

this video I will teach you guys about

and girls about variables which you will

quickly find yourself using extremely

frequently pretty much in every single

program you ever write variables act as

a placeholder for whatever you place in

them and it can be changed so they are

as you guessed variable so let's go

ahead and show some examples of these

variable variables so for starters let's

say we just have example var so what

this is and how you define a variable in

Python is you just type it out so

variables can have all kinds of fun

stuff in them you can do what's known as

camel casing or you can use a lot of

people will do like example var like

this and a lot of people even capitalize

their variables like this so they use

all caps and underscores honestly at the

end of the day it really doesn't matter

but um like I said a lot of you guys

have teachers or whatever and they get

pretty anal about this kind of stuff so

you know do whatever they say

but I do camel casing pretty much for

everything i camelcase

my variables my functions pretty much

all that stuff so um that is improper by

you know programming standards uh so

take that as you will anyway so example

var is our variable name and then you

just follow it with equals and we're

just going to say example 4 equals 55

for now and then we're going to print

out a example bar so now let's just save

and run that and sure enough it prints

out 55 you can also have example bar

equals 55 plus 32 so you can not only

have example bar equal uh just something

it can actually equal a quick operation

so we'll do this 87 an example of our

can also check this out can contain a


so in this case we have a very simple

function oh isn't this interesting

example of our equals

prints oops whoa

imagine neo as you say whoa anyway uh so

we knew that so let's run that and you

can see in the definition it you know

went whoa and we never actually even had

a call example for but if we call

example bar again we get whoa so now um

so you can put functions in there

and you can do uh some some other stuff

too that I'll show you guys in just one

moment called unpacking um try to think

of there's anything else actually I

think I've covered everything I really

want to cover um so let me delete I

delete that and let me show you guys one

last part of variables

that's pretty integral or useful and

that's going to be unpacking so when you

unpack a variable but you can do is you

could say like a common operation would

be like coordinates right so you could

say X comma y equals and then you could

say your coordinates are three five okay

now what that's going to do is it's

going to unpack this Python list into x

and y so what you can do now is we can

do stuff with our new variables and in

this case let's just print them run that

and you can see that it prints X which

is 3 and Y which is 5 pretty neat but

what if you try to do like this so now

you're trying to you've got two

variables but you've got three bits of

data that you're trying to unpack you're

going to get this error too many values

to unpack we'll talk about this again in

a little bit because I will have a bit

of a debugging basics later on but just

take note that it must be equal like you

must unpack the same number of variables

so for now I think that'll cover the

introduction of variables and all that

so if you guys have any questions about

variables feel free to post them below I

do respond to the comments otherwise

hopefully you guys learn something new

as always thanks for watching thanks for

all the support in the subscriptions and

until next time