Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
30 changes: 30 additions & 0 deletions lab_funcation_bouns.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@
def pyramid_pattern(num: int) -> str:
"""
Return one row of the pyramid pattern from num down to 1 as a string.
Example:
>>> pyramid_pattern(5)
'5 4 3 2 1'
"""
pyramid_list = []
for n in range(1, num + 1):
pyramid_list.insert(0, n)
return " ".join(map(str, pyramid_list))

def cheak(num: int) -> str:
"""
Return the full pyramid pattern from num down to 1 as a multi-line string.
Each line contains descending numbers starting from the current row number down to 1.
"""
result = ""
while num != 0:
result += pyramid_pattern(num) + "\n"
num -= 1
return result

# Get user input
user_number = int(input("Enter an integer number: "))
# Store the pattern in a variable
pattern = cheak(user_number)

# Print the final pattern
print(pattern)
25 changes: 25 additions & 0 deletions lab_function_1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,25 @@
def pyramid_pattern(num: int):
"""
Print one row of the pyramid pattern from num down to 1.
Example:
If num = 5, it prints: 5 4 3 2 1
"""
pyramid_list = []
for n in range(1, num + 1):
pyramid_list.insert(0, n)
print(*pyramid_list)

def cheak(num: int):
"""
Print the full pyramid pattern from num down to 1.
Calls pyramid_pattern for each row starting from num down to 1.
"""
while num != 0:
pyramid_pattern(num)
num -= 1

# Get user input
number = int(input("Enter integer number: "))

# Call function to print the pyramid pattern
cheak(number)