Robotics & Artificial Intelligence
Write a python program to print a pyramid using 'for' loop.
Python Control Flow
2 Likes
Answer
rows = 5
for i in range(1, rows + 1):
for j in range(rows - i):
print(" ", end="")
for k in range(1, 2 * i):
print("*", end="")
print()Output
*
***
*****
*******
*********
Answered By
3 Likes
Related Questions
Write a Python program to find the square of all elements between 1 to 20.
Write a Python program to demonstrate the use of the if-elif-else statements.
Write a program to store marks of your class students and show their percentage.
Write a program to implement a simple shopping cart system. In it user can add items, remove items, view the cart, and calculate the total cost.