For both the speed limit and the driver's speed, you can validate Python's input() function with a try-except blocks, wrapped in a while loop. The while loops allow for the program to "re-ask" the user for the valid input, such as in the first question of the speed limit to make sure it is within the range of 20 and 70 (combined with an if statement).
while True:
try:
spd_limit = int(input("What is the speed limit? "))
except ValueError:
print("Please enter valid integer number.")
continue
else:
if spd_limit >= 20 and spd_limit <= 70:
break
else:
print("Please enter speed limit between 20 and 70.")
continue
while True:
try:
driver_spd = int(input("What is the driver's speed? "))
except ValueError:
print("Please enter valid integer number.")
continue
else:
if driver_spd < spd_limit:
print("Driver was below the speed limit.")
continue
else:
over_limit = driver_spd - spd_limit
print(over_limit)
break
This is intended to run as a script, but this can be modified as a function, with one adjustment being to return the over_limit variable.