diff --git a/lab_funcation_bouns.py b/lab_funcation_bouns.py new file mode 100644 index 0000000..f16fc1b --- /dev/null +++ b/lab_funcation_bouns.py @@ -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) diff --git a/lab_function_1.py b/lab_function_1.py new file mode 100644 index 0000000..30656bf --- /dev/null +++ b/lab_function_1.py @@ -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)