xxxxxxxxxx
Enter the limit = 5
1
1 2
1 2 3
1 2 3 4
1 2 3 4 5
a=int(input("Enter the limit = "))
i=1
for i in range(1,a+1):
print("")
for j in range(1,i+1):
print(j,end=" ")
xxxxxxxxxx
# Define the number of rows
num_rows = 4
# Initialize start number
start_num = 1
# Loop for each row
for i in range(num_rows):
# Set the current number to the start number
current_num = start_num
# Loop for each column in the row
for j in range(i + 1):
# Print the current number followed by a space
print(current_num, end=" ")
# Increment the current number
current_num += 1
# Move to the next line after printing the row
print()
# Increment the start number for the next row
start_num += 1
xxxxxxxxxx
def horner(poly, n, x):
# Initialize result
result = poly[0]
# Evaluate value of polynomial
# using Horner's method
for i in range(1, n):
result = result*x + poly[i]
return result