Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Goal: Learn to write recursive functions with a base case. FF . . / home / codegrade / . pyenv / versions / 3 .

Goal: Learn to write recursive functions with a base case. FF..
/home/codegrade/.pyenv/versions/3.11.9/lib/python3.11/site-
packages/cg_feedback_helpers/_impl/writers.py:170:
cg_feedback_helpers._impl.writers. FeedbackAssertionError: 1
/home/codegrade/. pyenv/versions/3.11.9/lib/python3.11/site-
packages/cg_feedback_helpers/_impl/writers.py:170:
cg_feedback_helpers._impl.writers. FeedbackAssertionError: 1
2 failed, 2 passed in 0.04s
Unit test results:
Test print_tree
ox It should print a tree 8 tall
Reason:
E cg_feedback_helpers._impl.writers.FeedbackAssertionError: 1
It should print a tree 15 tall
Reason:
E cg_feedback_helpers._impl.writers.FeedbackAssertionError: 1
It should not print anything #1
It should not print anything #1
Feedback:
Expected value to be *, instead got *
Expected value to be *, instead got * While print_tree(11) should print:**]
]You can at most use one other function to achieve this, which should be named _print_tree.
You have to use recursion to complete this assignment.
Assignment: Write a function print_tree that takes an int parameter. This parameter is the
height of the tree to print. The tree's leaves should be asterisks and shaped as a triangle facing
up. At the base of the triangle, the tree should have a stem with a height of 1 if the tree is less
than 10 high, and a height of 2 otherwise, represented by the character "]". If the height is not a
positive number, it should print nothing.
For example, print_tree(5) should print:**]While print_tree(11) should print:
**
image text in transcribed

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_2

Step: 3

blur-text-image_3

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

Moving Objects Databases

Authors: Ralf Hartmut Güting, Markus Schneider

1st Edition

0120887991, 978-0120887996

More Books

Students also viewed these Databases questions