#Programs to improve your basics
def tri(n): #declaring function
for i in range(n): # i will be executed n times
for j in range(i): # j will be executed i times
print('*', end = ' ') # printing star in straight line
print() # for going to next line
tri(10) # argument passed as n = 10
in third line j is executing i times that is , when the value of i = 1 , j will execute 1 time by printing a " * " ,and by print() statement the execution will go to next line and when i = 2 , j will execute 2 times by printing " * " 2 times
output

Comments
Post a Comment