Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Question:Exercise 4: Write some code 9. Write a function named pyramid that (1) takes a positive integer n as a formal parameter, (2) draws a

Question:Exercise 4: Write some code 9. Write a function named pyramid that (1) takes a positive integer n as a formal parameter, (2) draws a pyramid of height n using *", as illustrated below for n = 3, 6, and (3) returns the number of symbols used. Use a for loop in the function. Call the function three times with n = 3, 6, 15 to test it one at a time. The caller must print the height of the pyramid and the number of *" used below each pyramid .image text in transcribed

Exercise 4: Write some code 9. Write a function named pyramid that (1) takes a positive integer n as a formal parameter, (2) draws a pyramid of height n using *", as illustrated below for n = 3,6, and (3) returns the number of symbols used. Use a for loop in the function. Call the function three times with n 3,6,15 to test it one at a time. The caller must print the height of the pyramid and the number of"*" used below each pyramid. Height of pyramid- 3 Number of symbols used- 8 Height of pyramid-6 Number of symbols used36

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions