#전역변수 global : 전 지역에서 사용할 수 있는 변수
name = '주현'
def hello():
print(name, '님 안녕하세요!')
hello()
print(name)
#지역변수 local : 특정 지역에만 사용할 수 있는 변수
def bye():
name2 = '담미'
print(name2, '님 안녕히 가세요!')
bye()
#print(name2) 지역변수는 정의한 함수 안에서만 사용할 수 있다
def add():
y = 8
print('x + y =', x + y)
x = 5
add()
'''
출력 결과가
안에서 만든 주스 : 사과주스
밖에서 만든 주스 : 포도주스
'''
juice = '포도주스'
def make_juice():
juice = '사과주스'
print('안에서 만든 주스 :', juice)
make_juice()
print('밖에서 만든 주스 :', juice)
To embed this project on your website, copy the following code and paste it into your website's HTML: