Python Programming Tutorial - 15 - Variable Scope

preview_player
Показать описание
Рекомендации по теме
Комментарии
Автор

1:31AM in the morning good freaking job Bucky

dangkhoa
Автор

here a useful code to understand variable scope

a = 1738

def corn():
print(a)

def fudge():
a = 3817
print(a)

corn()
fudge()
corn()

fudge changes the valeu of 'a' but corn can't see it

baleia
Автор

a can be defined after function definition and before function call as well.

def corn()
print(a)

a = 10
corn()


output: 10

HamidNourashraf
Автор

Thanks for clearing it out, Bucky! You're the best!

olaberglund
Автор

greetings from Costa Rica ...Best tutorials ever ...

juanjosegrafico
Автор

When i get a job as a professional programmer, will I be able to call my functions/methods things like tuna and beef? Imagine trying to go through the source code of something written like that :)

ethanwrightson
Автор

I thought they are called global and local variables

rileypurcell
Автор

The variable can also be used anywhere else outside the function/s (i.e below), not only if it's above it.

tvpcoder
Автор

When a variable is created inside a function is becomes a local variable to that function, you can still use that variable name outside the function as it is then global to the program;

a = 1234

def corn():
a = 7823
print(a)

def fudge():
print(a)

corn()
fudge()

BobRoffey
Автор

If you want a variable that is defined inside a function to be used by other functions than write global before the variable name.
Ex. Global a =272

harsh_jain
Автор

Thanks Bucky!Awesome job!Your videos are really helpful.

mirrors.of.reality
Автор

1:09  "Pretty simple 'prerum' right now . . . "

greatsea
Автор

What is the : symbol used for? I've always wondered.

maidsrage
Автор

bucky I believed there are two python tutorials in ur videos... one that is not HD and another is HD. and I cant find the hd one is ur playlist...
and If I searched, keep on ending up at the non-hd version of python tutorials

naqibjunaidy
Автор

When I try to run the same code as Bucky nothing gets printed in my run console pls help.
It just says: Process finished with exit code 0

sgangoly
Автор

How does the scope work if you are importing the functions from another file?

Say I have a in file 1 and try to call and modify it from file 2, what would that look like?

dl
Автор

your explanation is awesome. Can you help me what IDE you're using to execute it

prajnaneerukonda
Автор

idk if it is the version, but i, whit python 3.6.1, i can pick variables from outside a function.

leonardotornesello
Автор

function are mean they will not allow to use their variable

flow
Автор

When do we need to use singlequotes(' ') and doublequotes(" ")

nikhilb