You are on page 1of 9

Q1.

Print right angle triangle


with star.
*
**
***
****
*****
Code:
rows = int(input("Please Enter
the Total Number of Rows : "))
print("Right Angled Triangle
Star Pattern")
for i in range(1, rows + 1):
for j in range(1, i + 1):
print('*', end = ' ')
print()
Output:
Q2. Print opposite right angle
triangle with star.
*****
****
***
**
*
Code:
rows = int(input("Please Enter
the total Number of Rows : "))
print("Inverted Right Angle
Triangle of Stars")
i = rows
while(i > 0):
j=i
while(j > 0):
print('* ', end = ' ')
j=j-1
i=i-1
print()
Output:
Print a normal triangle with
star.
*
* *
* * *
* * * *
* * * * *
Code:
k=0
rows = 5
for i in range(1, rows+1):
for space in range(1, (rows-
i)+1):
print(end=" ")
while k != (2*i-1):
print("* ", end="")
k=k+1
k=0
print()
Output:

You might also like