Question

A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is...

A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is the number of steps, and whose output is the miles walked.

Output each floating-point value with two digits after the decimal point, which can be achieved as follows:
print('{:.2f}'.format(your_value))

Ex: If the input is:

5345

the output is:

2.67

Your program must define and call the following function. The function should return the amount of miles walked.
def steps_to_miles(user_steps)

answer must be in Phython 3

0 0
Add a comment Improve this question Transcribed image text
Answer #1

CODE:

def steps_to_miles(user_steps): #function to calculate total miles walked return user_steps/2000; #by dividing total steps by 2000 we will get total miles numberOfSteps=int(input("Enter number of steps: ")) #reading number of steps from user miles=steps_to_miles(numberOfSteps) #calling function to get total miles walked print('{:.2f}'.format(miles)) #printing function in desired format.that is printing only two decimals after 

CODE SCREENSHOT:

OUTPUT:

Please rate my answer if you liked it.

Add a comment
Know the answer?
Add Answer to:
A pedometer treats walking 2,000 steps as walking 1 mile. Write a program whose input is...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a function DrivingCost with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon

    Write a function DrivingCost with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the function is called with 5020.03 .1599, the function returns 7.89975 .Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three times.Output each floating-point value with two...

  • Write a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallo

    6.26 LAB: Driving cost - methodsWrite a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975.Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method three times.Output...

  • (C++) One lap around a standard high-school running track is exactly 0.25 miles

    17.1 LAB: Niles to track laps  (C++)One lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements.Ex. If the input is:1.5the output is:6.00Ex: If the input is:2.2the output is:8.80Your program must define and call a function: double...

  • Driving cost - methods

    3.14 LAB: Driving cost - methodsWrite a method drivingCost() with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. All items are of type double. If the method is called with 50 20.0 3.1599, the method returns 7.89975.Define that method in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both doubles). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your drivingCost() method three times.Output each...

  • A jiffy

    3.13 LAB: A jiffyA “jiffy” is the scientific name for 1/100th of a second. Given an input number of seconds, output the number of "jiffies."Output each floating-point value with two digits after the decimal point, which can be achieved as follows:System.out.printf("%.2f", yourValue);Ex: If the input is:15the output is:1500.00Your program must define and call a method:public static double secondsToJiffies(double userSeconds)

  • Python 3 please. 6.27 (Functions) HW: Driving cost - functions Write a function DrivingCost with input...

    Python 3 please. 6.27 (Functions) HW: Driving cost - functions Write a function DrivingCost with input parameters drivenMiles, milesPerGallon, and dollarsPerGallon, that returns the dollar cost to drive those miles. Ex: If the function is called with 50 20.0 3.1599, the function returns 7.89975. Define that function in a program whose inputs are the car's miles/gallon and the gas dollars/gallon (both floats). Output the gas cost for 10 miles, 50 miles, and 400 miles, by calling your DrivingCost function three...

  • PLEASE WRITE IN C++ 2.25 LAB: Driving costs Driving is expensive. Write a program with a...

    PLEASE WRITE IN C++ 2.25 LAB: Driving costs Driving is expensive. Write a program with a car's miles/gallon and gas dollars/gallon (both doubles) as input, and output the gas cost for 10 miles, 50 miles, and 400 miles. Output each floating-point value with two digits after the decimal point, which can be achieved by executing cout << fixed << setprecision(2); once before all other cout statements. Ex: If the input is: 20.0 3.1599 the output is: 1.58 7.90 63.20 Note:...

  • Write a program whose input is two integers and whose output is the two integers swapped....

    Write a program whose input is two integers and whose output is the two integers swapped. Write in C language 7.3 LAB: Swapping variables Write a program whose input is two integers and whose output is the two integers swapped. Ex: If the input is: 38 then the output is: 83 Your program must define and call a function. SwapValues returns the two values in swapped order. void SwapValues(int* userVali, int* userVal2) ACRIVITY 7.3.1: LAB: Swapping variables 0/10 ] main.c...

  • Code Program in C++ Language.5.9 LAB: Miles to track laps One lap around a standard...

    5.9 LAB: Miles to track lapsOne lap around a standard high-school running track is exactly 0.25 miles. Write a program that takes a number of miles as input, and outputs the number of laps.Ex: If the input is 1.5, the output is6Ex: If the input is 2.2, the output is8.8Your program must define and call a function:double MilesToLaps(double userMiles)

  • For this Java program I have to be implementing a Pedometer class. The driver file will...

    For this Java program I have to be implementing a Pedometer class. The driver file will be provided for you ( PedometerDriver.java ) and can be downloaded in Canvas. Write a stand alone class. Name your class Pedometer and source file Pedometer.java . Program 6 Overview Goals Class and File Naming Here is the Unified Modeling Language (UML) diagram for the Pedometer class. See the end of this document for information on how to read a UML document. Pedometer -...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT