Explains briefly what local scope is in Python
code
#!/usr/bin/env python
func_demo.py
basic function
scope of variable
def addme(val1,val2):
z = val1 + val2
this ok - local scope
z is only available in the function
print("In the function",z)
return z
x = int(input("Enter a value for x "))
y = int(input("Enter a value for y "))
this is not defined
local scope not global scope
#print(z)
total=addme(x,y)
print(total)
Смотрите видео local scope in Python онлайн без регистрации, длительностью часов минут секунд в хорошем качестве. Это видео добавил пользователь d p 02 Ноябрь 2020, не забудьте поделиться им ссылкой с друзьями и знакомыми, на нашем сайте его посмотрели 12 раз и оно понравилось 0 людям.