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)
8.11 LAB: Drawing a right side up triangle Write a recursive function called draw_triangle() that outputs lines of '*' t
-
- Site Admin
- Posts: 899603
- Joined: Mon Aug 02, 2021 8:13 am