上传文件至「week12」
This commit is contained in:
21
week12/ex3.py
Normal file
21
week12/ex3.py
Normal file
@@ -0,0 +1,21 @@
|
||||
try:from decimal import Decimal
|
||||
except:Decimal = float
|
||||
from continueanyway import ca
|
||||
|
||||
@ca
|
||||
def ValidateNumerical(i):
|
||||
try:
|
||||
ii = Decimal(i)
|
||||
print(f"{i} is a valid number")
|
||||
return ii
|
||||
except:raise TypeError(f"The given {i} is not a number")
|
||||
|
||||
def main():
|
||||
ValidateNumerical("10")
|
||||
ValidateNumerical(10.0)
|
||||
ValidateNumerical("dshjkfsdjhfkjsd")
|
||||
ValidateNumerical(10)
|
||||
return 0
|
||||
|
||||
if __name__ == '__main__':
|
||||
main()
|
||||
Reference in New Issue
Block a user