Distance Traveled
Assuming there are no accidents or delays, the distance that a car travels down the interstate can be calculated with the following formula:
def calculate_distance(speed, time):
"""
Function to calculate the distance traveled by a car.
Arguments:
- speed: The speed of the car in miles per hour.
- time: The time traveled in hours.
Returns:
- The distance traveled by the car in miles.
"""
# Calculate the distance using the formula: distance = speed * time
distance = speed * time
return distance
# Test the function
speed = 60 # miles per hour
time = 2 # hours
distance = calculate_distance(speed, time)
print(f"The car traveled {distance} miles.")
Executed output:
The car traveled 120 miles.