added 7-10

This commit is contained in:
2024-12-07 22:22:21 +02:00
parent 017145b529
commit 94318de22d
4 changed files with 85 additions and 0 deletions

View File

@@ -0,0 +1,15 @@
# Q10
# Receive input from the user
n = int(input("Enter a natural number (n): "))
# Variable to store the current number
current_number = 1
# Outer loop to print according to the number of rows
for row in range(1, n + 1):
# Inner loop to print the numbers for the current row
for col in range(row):
print(current_number, end=" ")
current_number += 1 # Increment the number
print() # Move to the next line after finishing the current row