Sectionย 4. Chapterย 3
single
Challenge: Calculating the Speed of a Car
Swipe to show menu
Task
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
Everything was clear?
Thanks for your feedback!
Sectionย 4. Chapterย 3
single
Ask AI
Ask AI
Ask anything or try one of the suggested questions to begin our chat