8.11 LAB: Drawing a right side up triangle Write a recursive function called draw_triangle() that outputs lines of '*' t

Business, Finance, Economics, Accounting, Operations Management, Computer Science, Electrical Engineering, Mechanical Engineering, Civil Engineering, Chemical Engineering, Algebra, Precalculus, Statistics and Probabilty, Advanced Math, Physics, Chemistry, Biology, Nursing, Psychology, Certifications, Tests, Prep, and more.
Post Reply
answerhappygod
Site Admin
Posts: 899603
Joined: Mon Aug 02, 2021 8:13 am

8.11 LAB: Drawing a right side up triangle Write a recursive function called draw_triangle() that outputs lines of '*' t

Post by answerhappygod »

8.11 LAB: Drawing a right side up triangle
Write a recursive function called draw_triangle() that outputs lines of '*' to form a right side up isosceles triangle. Function draw_triangle() has one parameter, an integer representing the base length of the triangle. Assume the base length is always odd and less than 20. Output 9 spaces before the first '*' on the first line for correct formatting.
Hint: The number of '*' increases by 2 for every line drawn.
Ex: If the input of the program is:
the function draw_triangle() outputs:
Ex: If the input of the program is:
the function draw_triangle() outputs:
Note: No space is output before the first '*' on the last line when the base length is 19.
THIS IS THE PROMPT I WAS GIVEN
# TODO: Write recursive draw_triangle() function here.
if __name__ == '__main__': base_length = int(input()) draw_triangle(base_length)
Join a community of subject matter experts. Register for FREE to view solutions, replies, and use search function. Request answer by replying!
Post Reply