Added week 9

This commit is contained in:
2026-05-11 09:43:05 +08:00
parent 734ca9d761
commit b512e04d5e
5 changed files with 99 additions and 0 deletions

27
week9/ex3.py Normal file
View 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()