Added week 9
This commit is contained in:
27
week9/ex3.py
Normal file
27
week9/ex3.py
Normal file
@@ -0,0 +1,27 @@
|
||||
try:
|
||||
from decimal import Decimal
|
||||
except:
|
||||
Decimal = float
|
||||
|
||||
def calculation(a,b):
|
||||
try:
|
||||
a,b = Decimal(a),Decimal(b)
|
||||
except:
|
||||
raise ValueError("Given number is not even a decimal!")
|
||||
|
||||
aa,s = a+b,a-b
|
||||
print(f"{a}+{b}={aa},{a}-{b}={s}")
|
||||
return aa,s
|
||||
|
||||
|
||||
def main():
|
||||
print('==Exercise 3==')
|
||||
|
||||
a,s = calculation(114,514)
|
||||
print(f"Return Value: {a},{s}")
|
||||
|
||||
print('==End Of Ex3==')
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user