Begin37. The speed of the first car is \(V_1\) km/h, the second - \(V_2\) km/h, the distance between them is \(S\) km. Determine the distance between them through \(T\) hours, if the cars initially move towards each other. This distance is equal to the modulus of the difference between the initial distance and the total path of the cars; Common path = time * total speed.

Solution in Python 3:

import random

V1,V2 = [random.randrange(50,70) for i in range(2)]
S = random.randrange(400,600)
T = random.randrange(1,6)
total_speed = V1 + V2
total_path = total_speed * T
D = abs(S - total_path)

print("1st vehicle speed:",V1)
print("2nd vehicle speed:",V2)
print("Time:",T)
print("Total speed:",total_speed)
print("Initial Distance between vehicles:",S)
print("Final Distance between vehicles:",D)