Added week 6

This commit is contained in:
2026-04-13 09:45:45 +08:00
parent 923c041dd6
commit 9b90ac4340
7 changed files with 139 additions and 0 deletions

24
week6/ex4.py Normal file
View File

@@ -0,0 +1,24 @@
from decimal import Decimal
#引入decimal模块是因为python不是默认高精浮点数
def main():
print('==Exercise 4==')
flag=True
while flag:
a = input("pls input a decimal:")
try:
a = Decimal(a)
flag=False
except :
print("pls input a decimal!")
d = a-int(a)
print(f"Decimal Part: {d if d else 'INTEGER'}")
print('==End Of Ex4==')
return 0
if __name__ == '__main__':
main()