A pedometer treats walking 1 step as walking 2.5 feet. Define a function named
feet_to_steps
that takes a float as a parameter, representing the number of feet walked, and returns the number of steps walked as an integer by usingint()
. Then, write a main program that reads the number of feet walked as an input, calls functionfeet_to_steps()
with the input as an argument, and outputs the number of steps returned fromfeet_to_steps()
.Use floating-point arithmetic to perform the conversion.
Note: Converting a float to an integer may affect the result’s
accuracy.
if __name__ == "__main__":
def feet_to_steps(feet_walked):
steps = feet_walked / 2.5
return round(steps)
feet_walked = float(input())
steps_walked = feet_to_steps(feet_walked)
print(steps_walked)
New contributor
2