Semaine 4, jour 5
This commit is contained in:
31
Semaine_04/Divers/main.py
Normal file
31
Semaine_04/Divers/main.py
Normal file
@@ -0,0 +1,31 @@
|
||||
from typing import TypedDict
|
||||
|
||||
|
||||
def addition(*args): # args => tuple (2,3,4,5,6,6,6,7,7,8,9)
|
||||
return sum(args)
|
||||
|
||||
print(addition(2,3,4,5))
|
||||
|
||||
livres = [
|
||||
{"titre": "1984", "auteur": "Orwell"},
|
||||
{"titre": "1983", "auteur": "Orwella"},
|
||||
{"titre": "1985", "auteur": "Orwell"}
|
||||
]
|
||||
|
||||
|
||||
def display_infos(**kwargs): # kwargs => dict {"Titre": "Scandale", "Auteur": "Marlène Schiappa"}
|
||||
resultats = []
|
||||
for livre in livres:
|
||||
if "auteur" in kwargs and kwargs["auteur"].lower() in livre["auteur"]:
|
||||
resultats.append(livre)
|
||||
if "titre" in kwargs and kwargs["titre"].lower() in livre["titre"]:
|
||||
resultats.append(livre)
|
||||
return resultats
|
||||
|
||||
infos: dict[str | int, str | int] = {"age": 23, "nom": "Albatar", "is_admin" : False}
|
||||
|
||||
class Criteres(TypedDict):
|
||||
auteur: NotRequired[str]
|
||||
titre: NotRequired[str]
|
||||
|
||||
print(CONSTANTES["db_name"])
|
||||
Reference in New Issue
Block a user