127k views
2 votes
For question 2 you will need to write your own Python code. Think through the problem, and re-read if necessary. Determine how you might solve the problem logically. Think of what variables you might need to store temporary values. Your friend was bragging about how many stairs he climbed each day because of his apartment location on the fifth floor. Calculate how many times your friend would have to go down then back up the stairs to reach his fifth floor apartment to reach 100, 500, 1000 and 5000 steps. The apartments all have vaulted ceilings, so use 16 steps per floor in your calculations. Remember to count down and back up as one trip. You will also reuse the variable that contains the target number of steps. Round up. HINT: take a look at previous question, and the use of import math and math.ceil(). Recommended variable names you will need for this question: steps_per_floor, floor, target_steps, trips >>>: Write a program that calculates the total number of trips given 100, 500, 1000 or 5000 daily steps, 16 steps per floor, and down and back up the stairs represents one trip. Re-use the target_steps variable. Round the number of trips up to the nearest whole integer. >>>: Display the number of trips for each of the four step counts, using the following example, illustrating the output for 100 steps. Add the other three results below the 100 steps result.

User Kgibbon
by
4.6k points

1 Answer

2 votes

Answer:

It has to be performed a minimum of 1 trips to do 100 steps

It has to be performed a minimum of 4 trips to do 500 steps

It has to be performed a minimum of 7 trips to do 1000 steps

It has to be performed a minimum of 32 trips to do 5000 steps

All trips need to be 44

Step-by-step explanation:

open python console and execute the .py code bellow:

import math

floor_steps=16

floor=5

total=0

target_steps=2*floor_steps*floor

trips=100/(target_steps)

trips= math.ceil(trips)

total+=trips

print("It has to be performed a minimum of ",trips," trips to do 100 steps")

trips=500/(target_steps)

trips= math.ceil(trips)

total+=trips

print("It has to be performed a minimum of ",trips," trips to do 500 steps")

trips=1000/(target_steps)

trips= math.ceil(trips)

total+=trips

print("It has to be performed a minimum of ",trips," trips to do 1000 steps")

trips=5000/(target_steps)

trips= math.ceil(trips)

total+=trips

print("It has to be performed a minimum of ",trips," trips to do 5000 steps")

print("All trips need to be ",total)

User Sichinumi
by
5.1k points