#### Answer

40 km/h

#### Work Step by Step

Speed is defined as distance over time, therefore the average speed is just the total distance divided by the amount of time it took to drive that distance.
There are two segments in the problem:
1) The car drives 40km at 30km/h
2) The car drives 40km at 60km/h
We need to find the time the car spent in each segment. To do so we divide the distance driven by the speed at which the car was traveling.
For segment 1 we have 40km/(30km/h) = 1.33 h
For segment 2 we have 40km/(60km/h) = 0.667h
We have a total of 2hr. Since the total trip was 80 km and it took 2 hours the average speed is 80/2 = 40km/h