This commit is contained in:
hugogogo
2025-10-26 17:24:58 +01:00
parent 5fc979681c
commit be2442e222

24
d00/ex04/whatis.py Normal file
View File

@@ -0,0 +1,24 @@
def check_parity(args: list[str]):
if len(args) == 0:
return
if len(args) > 1:
print("AssertionError: more than one argument is provided")
return
arg = args[0]
try:
number = int(arg)
except ValueError:
print("AssertionError: argument is not an integer")
return
if number % 2 == 0:
print("I'm Even.")
else:
print("I'm Odd.")
# execute module as a script : https://docs.python.org/3.10/tutorial/modules.html#executing-modules-as-scripts
if __name__ == "__main__":
# https://docs.python.org/3.10/library/sys.html
import sys
check_parity(sys.argv[1:])