satya

Tuesday, September 1, 2020

Program 5

 Program 5

Use a for loop to print a triangle like the one below. Allow the user to specify how high the triangle should be.

 *

**

***

****

Program:

height=int(input("Enter the height of the Triangle:"))

for i in range(1,height+1):

    for j in range(i):

        print("*",end="")

    print("")


Output:

Enter the height of the Triangle:6
*
**
***
****
*****
******

No comments:

Post a Comment

Program 30

                                                                         Program 30 Write a Python class to implement pow(x, n). class Pow1:...