Skip to content

Commit 5ad6959

Browse files
committed
Use descriptive parameter names in pyramid patterns
- Replace generic parameter 'n' with descriptive 'height' - Update all function signatures and docstrings - Maintain functionality while improving code readability - All ruff checks pass
1 parent 83e52f5 commit 5ad6959

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

other/pyramid_patterns.py

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,23 +29,23 @@
2929

3030
# No import needed for None type annotation
3131

32-
def pyramid(n: int) -> None:
33-
"""Prints a pyramid pattern of height n."""
34-
for i in range(n):
35-
print(" " * (n - i - 1) + "*" * (2 * i + 1))
32+
def pyramid(height: int) -> None:
33+
"""Prints a pyramid pattern of the specified height."""
34+
for i in range(height):
35+
print(" " * (height - i - 1) + "*" * (2 * i + 1))
3636

3737

38-
def inverted_pyramid(n: int) -> None:
39-
"""Prints an inverted pyramid pattern of height n."""
40-
for i in range(n - 1, -1, -1):
41-
print(" " * (n - i - 1) + "*" * (2 * i + 1))
38+
def inverted_pyramid(height: int) -> None:
39+
"""Prints an inverted pyramid pattern of the specified height."""
40+
for i in range(height - 1, -1, -1):
41+
print(" " * (height - i - 1) + "*" * (2 * i + 1))
4242

4343

44-
def diamond(n: int) -> None:
45-
"""Prints a diamond pattern of height n."""
46-
pyramid(n)
47-
for i in range(n - 2, -1, -1):
48-
print(" " * (n - i - 1) + "*" * (2 * i + 1))
44+
def diamond(height: int) -> None:
45+
"""Prints a diamond pattern of the specified height."""
46+
pyramid(height)
47+
for i in range(height - 2, -1, -1):
48+
print(" " * (height - i - 1) + "*" * (2 * i + 1))
4949

5050

5151
if __name__ == "__main__":

0 commit comments

Comments
 (0)