added 7-10
This commit is contained in:
15
basic programming/2nd task/10.py
Normal file
15
basic programming/2nd task/10.py
Normal 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
|
||||
Reference in New Issue
Block a user