Skip to content

Commit df1e22d

Browse files
committed
TR updates, first round
1 parent 2ed326d commit df1e22d

File tree

3 files changed

+21
-2
lines changed

3 files changed

+21
-2
lines changed

python-variables/greeting.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
def greet(name, verbose=False):
2+
if verbose:
3+
print(f"Hello, {name}! It's great to see you!")
4+
else:
5+
print(f"Hello, {name}!")
6+
7+
8+
greet("Pythonista")
9+
greet("Pythonista", verbose=True)

python-variables/scopes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,9 @@ def inner_func():
1515
# Local scope
1616
local_variable = "local"
1717
print(f"Hi from the '{local_variable}' scope!")
18+
print(f"Hi from the '{global_variable}' scope!")
19+
print(f"Hi from the '{nonlocal_variable}' scope!")
1820

19-
print(f"Hi from the '{global_variable}' scope!")
20-
print(f"Hi from the '{nonlocal_variable}' scope!")
2121
inner_func()
2222

2323

python-variables/toggle.py

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
toggle = True
2+
3+
for _ in range(4):
4+
if toggle:
5+
print(f"✅ toggle is {toggle}")
6+
print("Do something...")
7+
else:
8+
print(f"❌ toggle is {toggle}")
9+
print("Do something else...")
10+
toggle = not toggle

0 commit comments

Comments
 (0)