In: Computer Science
write a program that creates steps. You are expected to take in a single positive integer which will be used as the number of steps in your stair case. The program only accepts integers greater than 0 and less than 500. If 0 is entered a message stating "Your staircase has no steps." and if the user enters a value greater than or equal to 500, a message stating "I can't build a staircase that tall." For all other values not within the valid range or not integers an "Invalid staircase size provided." will be displayed to the user. The program will always run only once for each user input. One thing to note, the messages should be the return string from your printSteps() function and printed from the calling function.
Additional Requirements:
1. The very first step in the stair case will be left aligned and for each subsequent level the step will move above and to the right of the prior step.
2. There are no spaces after the right of any of the steps.
3. The bottom most row ends without a new line.
4. Here is the py file you should add your code to, this should be the only file you submit.
''' This functions asks the user for the number of steps
they want to climb, gets the value provided by the user
and returns it to the calling function'''
def getUserInput():
#your code belongs here
''' This function takes the number of steps as an unput
parameter,
creates a string that contains the entire steps based on the user
input
and returns the steps string to the calling function
'''
def printSteps(stepCount):
#your code belongs here
'''Within this condition statement you are to write the code
that
calls the above functions when testing your code the code below
this
should be the only code not in a function and must be within the
if
statement. I will explain this if statement later in the
course.'''
if __name__ == "__main__":
#your code belongs here
Below is a screen shot of the python program to check indentation. Comments are given on every line explaining the code. Below is the output of the program: Below is the code to copy: #CODE STARTS HERE---------------- def getUserInput(): #Get user input while True: #Loops until valid input is given try: #Get user input num = int(input("Enter the number of steps: ")) if num == 0: #Print message if input is 0 print("Your staircase has no steps.") continue if num>=500: #Print message if input is more than 500 print("I can't build a staircase that tall.") continue if num<0: raise Exception return num #Return input except: print("Invalid staircase size provided.") def printSteps(stepCount): step = "" #Stores the output stairs string for i in range(stepCount-1,-1,-1): #loop backwards and print the steps step+=" "*(i*3)+"__|\n" #steps string return step #Return value if __name__ == "__main__": num = getUserInput() #Function call to get user input print(printSteps(num)) #Call print function and print it #CODE ENDS HERE------------------