Skip to content

Commit df51d05

Browse files
authored
Create tutorial_29.py
1 parent 7b0514e commit df51d05

File tree

1 file changed

+20
-0
lines changed

1 file changed

+20
-0
lines changed

code/tutorial_29.py

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
first = 'Alice'
2+
last = 'Pringtin'
3+
visited = 0
4+
5+
def greet():
6+
global last, visited
7+
first = 'Mark'
8+
last = 'Pringston'
9+
visited += 1
10+
print('=============================')
11+
print(f'Welcome, {first} {last}')
12+
print('Glad to have you.')
13+
print('Times visited =', visited)
14+
print('-----------------------------')
15+
16+
greet()
17+
greet()
18+
19+
print('Global variables "last", and "visited" are now:', last, visited)
20+
print('Global variable "first" has not changed:', first)

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy