Skip to content

Functions lab #15

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
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
10 changes: 10 additions & 0 deletions functionBonus.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
def get_pattern(n: int) -> str:
result = []
for i in range(n, 0, -1):
line = ' '.join(str(x) for x in range(i, 0, -1))
result.append(line)
return '\n'.join(result)

# Example usage
pattern_result = get_pattern(5)
print(pattern_result)
11 changes: 11 additions & 0 deletions labFunction.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
## Create a function that takes 1 parameter of type int ,
# then it prints out the result formatted like the following patter (if we give it 5 for example):

def print_pattern(n: int):
for i in range(n, 0, -1):
# Create a list of numbers from i down to 1
line = ' '.join(str(x) for x in range(i, 0, -1))
print(line)

# Example usage
print_pattern(5)