Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

PYTHON CODING QUESTION As part of your new exercise regime, you\'re doing a lot

ID: 3757482 • Letter: P

Question

PYTHON CODING QUESTION

As part of your new exercise regime, you're doing a lot of drills up and down stairs. In order to help you get motivated for tomorrow's set of stairs, you decide to write a program to visualise how many stairs you're going to need to run up. Write a program to ask the user for how many steps to draw. The user will always enter an integer greater than zero. For example, if the user entered 4, your program should output: How many steps? 4 The horizontal lines are created using underscores (_) and the vertical lines using the pipe character (|). Here is another example teraction between your program and the user: How many steps? 1

Explanation / Answer

#Write a program to ask the user for how many steps to draw
def drawSteps():
print("How many steps? ",end='')
steps = int(input())
#printing first horizontal step
print('__')
d=2
for i in range(0,steps-1):
for j in range(0,d):
print(' ',end='')
print('|_')
d = d+1
for j in range(0,d):
print('_',end='')
print('_|')

# Write a program that display the floor numbers on an elevator that is going...
def showFloor():
print("Current floor: ",end='')
currentFloor = int(input())
print("Destination floor: ",end='')
destinationFloor = int(input())
#printing the floor from current floor to destination
for i in range(currentFloor,destinationFloor):
print('Level '+str(i))
  


#running first program
drawSteps()


print(" ")
#running second program
showFloor()
  
  

# Here is output

How many steps? 12
__
|_
|_
|_
|_
|_
|_
|_
|_
|_
|_
|_
______________|


Current floor: 3
Destination floor: 10
Level 3
Level 4
Level 5
Level 6
Level 7
Level 8
Level 9
>>>