Thanks for the tips. Didn't know about the style guide - Heading over to there ASAP.
For not using uppercase letters, then, measUnits would become meas_units.
I appreciate your comment about not needing to use "meas" everywhere, but I have reading issues and it helps me follow what's going on :)
I will also check out "f-strings". Are they related to g-strings
EDIT - updated script:
For not using uppercase letters, then, measUnits would become meas_units.
I appreciate your comment about not needing to use "meas" everywhere, but I have reading issues and it helps me follow what's going on :)
I will also check out "f-strings". Are they related to g-strings
EDIT - updated script:
# Convert millivolts to engineering units print("4-20 mA to Engineering units convertor") print("") def main(): # Set engineering units and range meas_units = input("Enter the units of measurement: ") # Input minimum value of measurement range while True: try: meas_min = float(input("Enter the minimum measurement value: ")) except ValueError: print("Must be a numeric value...") continue else: break meas_min2 = abs(float(meas_min)) # removes "minus" bit # Input maximum value of measurement range while True: try: meas_max = float(input("Enter the maximum measurement value: ")) except ValueError: print("Must be a numeric value...") continue else: break # Display measurement range meas_range = float(meas_min2) + float(meas_max) print(f"Measurement range is {meas_min} to {meas_max} {meas_units}") # Input measured value while True: try: raw_value = float(input("Input mV value: ")) except ValueError: print("Must be a numeric value...") continue else: break # Calculate measured value step1 = float(raw_value) - 400 step2 = step1 / 1600 meas_value = (step2 * meas_range) - meas_min2 output = round(meas_value,2) print("Measured value is {} {}".format(output, meas_units)) restart = input("Do you want to convert another value? Y/N: ") print("") if restart.lower() == 'y': main() else: print("Goodbye") main()