Added week 6
This commit is contained in:
24
week6/ex4.py
Normal file
24
week6/ex4.py
Normal 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()
|
||||
Reference in New Issue
Block a user