Sovi.AI - AI Math Tutor

Scan to solve math questions

QUESTION IMAGE

lab activity 4.4.1: lab: step counter a pedometer treats walking 1 step…

Question

lab activity 4.4.1: lab: step counter 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 using int(). then, write a main program that reads the number of feet walked as an input, calls function feet_to_steps() with the input as an argument, and outputs the number of steps returned from feet_to_steps(). use floating - point arithmetic to perform the conversion. note: converting a float to an integer may affect the results accuracy. ex if the input is: 150.5 the output is: 60 the program must define and call the following function: def feet_to_steps(user_feet)

Explanation:

Step1: Define the function

def feet_to_steps(user_feet):
    steps = int(user_feet / 2.5)
    return steps

Step2: Write the main program

if __name__ == "__main__":
    user_feet = float(input())
    print(feet_to_steps(user_feet))

Answer:

def feet_to_steps(user_feet):
    steps = int(user_feet / 2.5)
    return steps

if __name__ == "__main__":
    user_feet = float(input())
    print(feet_to_steps(user_feet))