This commit is contained in:
hugogogo
2025-10-25 19:50:36 +02:00
parent e9b31175f6
commit 05487357f0
2 changed files with 32 additions and 0 deletions

18
d00/ex02/find_ft_type.py Normal file
View File

@@ -0,0 +1,18 @@
def all_thing_is_obj(object: any) -> int:
# https://docs.python.org/3.10/library/functions.html?highlight=type#type
ofType = type(object)
match object:
case list():
print("List : ", ofType)
case tuple():
print("Tuple : ", ofType)
case set():
print("Set : ", ofType)
case dict():
print("Dict : ", ofType)
case str():
print(object + " is in the kitchen : ", ofType)
case _:
print("Type not found")
return 42

14
d00/ex02/tester.py Normal file
View File

@@ -0,0 +1,14 @@
from find_ft_type import all_thing_is_obj
ft_list = ["Hello", "tata!"]
ft_tuple = ("Hello", "toto!")
ft_set = {"Hello", "tutu!"}
ft_dict = {"Hello" : "titi!"}
all_thing_is_obj(ft_list)
all_thing_is_obj(ft_tuple)
all_thing_is_obj(ft_set)
all_thing_is_obj(ft_dict)
all_thing_is_obj("Brian")
all_thing_is_obj("Toto")
print(all_thing_is_obj(10))