31 lines
876 B
Python
31 lines
876 B
Python
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"]) |