Skip to content

Commit cd16c84

Browse files
Rename variables
1 parent a582ceb commit cd16c84

File tree

2 files changed

+19
-19
lines changed

2 files changed

+19
-19
lines changed

getting-started/repl.md

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -218,9 +218,9 @@ Expected output: `6`
218218
**English:**
219219

220220
```python
221-
let x = 2
222-
let z = 3
223-
print(x + z)
221+
let x1 = 2
222+
let z1 = 3
223+
print(x1 + z1)
224224

225225
let total = 0
226226
for idx in range(4):
@@ -231,9 +231,9 @@ print(total)
231231
**French:**
232232

233233
```python
234-
soit x = 2
235-
soit y = 3
236-
afficher(x + y)
234+
soit x1 = 2
235+
soit y1 = 3
236+
afficher(x1 + y)
237237

238238
soit total = 0
239239
pour i dans intervalle(4):

language-guide/functions-classes.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -131,8 +131,8 @@ greet("Carol", times=3) # Hello, Carol! (×3)
131131
### Type Annotations
132132

133133
```python
134-
def add(x: int, y: int) -> int:
135-
return x + y
134+
def add(x: int, b: int) -> int:
135+
return x + b
136136

137137
def process(items: list, limit: int = 10) -> dict:
138138
return {i: items[i] for i in range(min(limit, len(items)))}
@@ -226,8 +226,8 @@ def log_calls(func):
226226
return wrapper
227227

228228
@log_calls
229-
def add(x, y):
230-
return x + y
229+
def add(x, b):
230+
return x + b
231231

232232
add(3, 4)
233233
# Calling add
@@ -265,7 +265,7 @@ def my_decorator(func):
265265

266266
```python
267267
let square = lambda x: x ** 2
268-
let add = lambda x, y: x + y
268+
let add = lambda x, b: x + b
269269
let clamp = lambda val, lo, hi: max(lo, min(hi, val))
270270

271271
print(square(5)) # 25
@@ -481,22 +481,22 @@ print(temp.fahrenheit) # 32.0
481481
class Vector:
482482
def __init__(self, x, y_val):
483483
self.x = x
484-
self.y = y_val
484+
self.y_val = y_val
485485

486486
def __add__(self, other):
487-
return Vector(self.x + other.x, self.y + other.y)
487+
return Vector(self.x + other.x, self.y_val + other.y_val)
488488

489489
def __mul__(self, scalar):
490-
return Vector(self.x * scalar, self.y * scalar)
490+
return Vector(self.x * scalar, self.y_val * scalar)
491491

492492
def __len__(self):
493493
return 2
494494

495495
def __repr__(self):
496-
return f"Vector({self.x}, {self.y})"
496+
return f"Vector({self.x}, {self.y_val})"
497497

498498
def __eq__(self, other):
499-
return self.x == other.x and self.y == other.y
499+
return self.x == other.x and self.y_val == other.y_val
500500

501501

502502
let v1 = Vector(1, 2)
@@ -517,11 +517,11 @@ from dataclasses import dataclass, field
517517
@dataclass
518518
class Point:
519519
x: float
520-
y: float
520+
y_coord: float
521521
label: str = ""
522522

523523
def distance_from_origin(self):
524-
return (self.x**2 + self.y**2) ** 0.5
524+
return (self.x**2 + self.y_coord**2) ** 0.5
525525

526526

527527
@dataclass
@@ -534,7 +534,7 @@ class Polygon:
534534

535535

536536
let p = Point(3.0, 4.0, "A")
537-
print(p) # Point(x=3.0, y=4.0, label='A')
537+
print(p) # Point(x=3.0, y_coord=4.0, label='A')
538538
print(p.distance_from_origin()) # 5.0
539539
```
540540

0 commit comments

Comments
 (0)