From 9b62e27176c94c2060b84998bb8d3af6cf3b60c1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D8=B1=D8=B2=D8=A7=D9=86=20=D8=A7=D9=84=D9=85=D8=B7=D9=8A?= =?UTF-8?q?=D8=B1=D9=8A?= Date: Thu, 19 Feb 2026 12:37:47 +0300 Subject: [PATCH] Functions 101 lab --- lab_functions_101.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 lab_functions_101.py diff --git a/lab_functions_101.py b/lab_functions_101.py new file mode 100644 index 0000000..a566cc5 --- /dev/null +++ b/lab_functions_101.py @@ -0,0 +1,27 @@ +def print_pattern(n: int): + """Print a descending number pattern from n down to 1 in multiple lines.""" + for i in range(n, 0, -1): + for j in range(i, 0, -1): + print(j, end=" ") + print() + +print_pattern(5) + +def pattern_as_string(n: int) -> str: + """Return the same descending number pattern as a single string.""" + result = "" + for i in range(n, 0, -1): + for j in range(i, 0, -1): + result += str(j) + " " + result += "\n" + return result + + +output = pattern_as_string(5) +print(print_pattern.__doc__) + +print(output) + + + +