Challenge: Calculating the Speed of a Car
Swipe to start coding
If we know the distance a car has traveled and the time it took to cover that distance, we can calculate its average speed using the formula:
Speed = Distance / Time Taken
The distance is measured in meters and the time in seconds.
Use the following values in your calculation: Distance = 1000, Time Taken = 120.
Your tasks:
- Define a function called
calcSpeed. - Declare the variables
distanceandtimeTakeninside the function using the values above. - Calculate the speed using the formula.
- Return the calculated speed.
Solution
Thanks for your feedback!
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat
Awesome!
Completion rate improved to 1.35
Challenge: Calculating the Speed of a Car
Swipe to show menu
Swipe to start coding
If we know the distance a car has traveled and the time it took to cover that distance, we can calculate its average speed using the formula:
Speed = Distance / Time Taken
The distance is measured in meters and the time in seconds.
Use the following values in your calculation: Distance = 1000, Time Taken = 120.
Your tasks:
- Define a function called
calcSpeed. - Declare the variables
distanceandtimeTakeninside the function using the values above. - Calculate the speed using the formula.
- Return the calculated speed.
Solution
Thanks for your feedback!
single