Lecture 11/17/2026
This commit is contained in:
parent
07b9e54bf0
commit
bf3265103a
44 changed files with 1195 additions and 3 deletions
19
lecture20261117/try/try04.py
Normal file
19
lecture20261117/try/try04.py
Normal file
|
|
@ -0,0 +1,19 @@
|
|||
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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue