while writing the code, you can embed semantics check into the code, and control with a variable.
Example:
Example:
debug = True def getDistance(): Km = float(input("How many kilometers is the race? ")) miles = Km * 0.62 #would be Km * 1.61 if converting Kilometers to miles if debug: print(f'semantic check: km = miles: {miles} / 0.62 = {miles / 0.62}\n') print("In that case, the distance in miles is " + str(miles) + " miles.") return miles,Km miles, Km = getDistance()result is debug == 1
Output:How many kilometers is the race? 15.4
semantic check: km = miles: 9.548 / 0.62 = 15.4
In that case, the distance in miles is 9.548 miles.
>>>
KeyboardInterrupt
>>>
note: f-string for python 3.6 and newer, on older versions use:print('semantic check: km = miles: {} / 0.62 = {}\n'.format(miles, miles / 0.62))