Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

-Write a Python function Pyramid which takes a positive int value as the formal

ID: 3779262 • Letter: #

Question

-Write a Python function Pyramid which takes a positive int value as the formal parameter and returns no value. The value determines the number of rows of the pyramid. A pyramid has one star at the top and the number of stars increments by two on each subsequent row. Starter code below. ef Pyramid (n): ft Your code goes here yramid0: for i in range(5.12.3): Pyramid (i) print0 -Use the starter code to begin with. -use either for loops or while loops. -Spaces and stars must be printed one at a time. -Do not modify the tes rt0 function. on each row of the triangle, you must draw a number of space(s) first, using a while loop, before star(s). To find an algorithm, you may want to analyze the relationship among the number of spaces, the number of stars, and the row number. The output should be like the output below.

Explanation / Answer

'''Defines function Test_pyramix'''
def test_pyramid():
for i in range(5, 12, 3):
Pyramid(i);
  
'''Defines function Pyramid'''
def Pyramid(k):
'''Loops till k value'''
for j in range(1,k):
'''Prints space and star'''
print(' '*(k-j),'* '*(j))

'''Calls test_pyramid function'''
test_pyramid()

Optput:

*
* *
* * *
* * * *
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
*
* *
* * *
* * * *
* * * * *
* * * * * *
* * * * * * *
* * * * * * * *
* * * * * * * * *
* * * * * * * * * *