Question: Python: Requirement: 1 2 3 Use of recursion Not used Used but not accurately The problem was solved using recursion Drawing of hourglass Doesn't print
Python:
Requirement:
| 1 | 2 | 3 | |
| Use of recursion | Not used | Used but not accurately | The problem was solved using recursion |
| Drawing of hourglass | Doesn't print neatly | Prints but the spaces are not evenly distributed | Prints as expected |
| User Interaction | Doesn't allow the user to enter an integer | Allows the user to enter an integer but doesn't validate the input | Allows the user to enter an integer and validates the input |
The program reads a single integer from the user. If that integer is less than 1, it prints an error message and stops. The hourglass base case with input 1 displays two lines with one star on each line. Otherwise, it prints a pattern of asterisks or stars (*) as shown below for an input of 4. Note that there are four stars (and spaces) on the first and last lines. ("_" is space)
*_*_*_*_ _*_*_*_ __*_*_ ___*_ __*_*_ _*_*_*_ *_*_*_*_
The program must not contain loops. Use recursion!
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
