Question: Python HELP!! # Goal: # Write a function triangle(n) to output a right triangle shaping as: # ***** # **** # *** # ** #
Python HELP!!
# Goal: # Write a function triangle(n) to output a right triangle shaping as: # ***** # **** # *** # ** # * # - Its base and height are both n. The above example is for n=5 # - The function output is a single string consisting n lines # with no space in the first line # - triangle(n) must call recursiveTriangle once # - recursiveTriangle(k, n) returns a string # including the LAST k lines of the triangle # - recursiveTriangle(k, n) must make a RECURSIVE CALL # - Each function must RETURN A STRING, NOT PRINTING # - You may create an extra function to call from # recursiveTriangle
def triangle(n): # code just one line
def recursiveTriangle(k, n): # Write a recursive function body
### To check print(recursiveTriangle(3, 5)) print(triangle(8)) # This should output # *** # ** # * # #******** # ******* # ****** # ***** # **** # *** # ** # *
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
