7.2 Mario (Py)

What to do
In a file called mario.py in a folder called sentimental-mario-less, write a program that recreates a half-pyramid using hashes (#) for blocks, exactly as you did in Problem Set 2. Your program this time should be written in Python!
Specification
- To make things more interesting, first prompt the user with
get_intfor the half-pyramidβs height, a positive integer between1and8, inclusive. - If the user fails to provide a positive integer no greater than
8, you should re-prompt for the same again. - Then, generate (with the help of
printand one or more loops) the desired half-pyramid. - Take care to align the bottom-left corner of your half-pyramid with the left-hand edge of your terminal window.
How to Test
Youβre encouraged to test your code on your own for each of the following.
- Run your program as
python mario.pyand wait for a prompt for input. Type in-1and press enter. Your program should reject this input as invalid, as by re-prompting the user to type in another number. - Run your program as
python mario.pyand wait for a prompt for input. Type in0and press enter. Your program should reject this input as invalid, as by re-prompting the user to type in another number. - Run your program as
python mario.pyand wait for a prompt for input. Type in1and press enter. Your program should generate the below output. Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line.
#- Run your program as
python mario.pyand wait for a prompt for input. Type in2and press enter. Your program should generate the below output. Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line.
#
##- Run your program as
python mario.pyand wait for a prompt for input. Type in8and press enter. Your program should generate the below output. Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line.
#
##
###
####
#####
######
#######
########- Run your program as
python mario.pyand wait for a prompt for input. Type in9and press enter. Your program should reject this input as invalid, as by re-prompting the user to type in another number. Then, type in2and press enter. Your program should generate the below output. Be sure that the pyramid is aligned to the bottom-left corner of your terminal, and that there are no extra spaces at the end of each line.
#
##- Run your program as
python mario.pyand wait for a prompt for input. Type infooand press enter. Your program should reject this input as invalid, as by re-prompting the user to type in another number. - Run your program as
python mario.pyand wait for a prompt for input. Do not type anything, and press enter. Your program should reject this input as invalid, as by re-prompting the user to type in another number.
How to Submit
- Click and accept the Homework Link on the homework main page for this week.
- Complete each assignment for this week in the Github Codespaces environment.
- Save and click βCommit changesβ.
- The autograder runs automatically; see the Actions tab for feedback.