2026fa_cse160/lecture20261117/try/try04.py
2026-11-17 12:30:27 -05:00

19 lines
433 B
Python

import sys
def getFloatValue(message):
try:
data1 = float(input(message))
except:
print(f"Invalid value for a floating point number. ")
sys.exit(-2)
return data1
data1 = getFloatValue("Enter value for the dividend ")
data2 = getFloatValue("Enter value for the divisor ")
try:
quotient = data1/data2
print(f"{data1}/{data2} = {quotient}")
except:
print(f"Invalid value. Division by zero is not allowed.")
sys.exit(-1)