-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmain.py
More file actions
67 lines (53 loc) · 1.64 KB
/
main.py
File metadata and controls
67 lines (53 loc) · 1.64 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
"""
This module randomly assigns household tasks to children.
"""
import random
kids = ["Yann", "Lana", "Alice"]
tasks = [
"Ranger la chambre",
"Faire la vaisselle",
"Passer l'aspirateur dans la maison",
"Balayer le sol de la cuisine",
"Sortir les poubelles",
"Essuyer la table après les repas",
"Laver les vitres",
"Aider à préparer le dîner",
"Plier et ranger le linge",
"Arroser les plantes",
"Faire une machine",
"Etendre le linge",
"Nettoyer la cuisinière"
]
def assign_tasks():
"""
Assigns a random task from the tasks list to each kid in the kids list.
Parameters:
kids (list): A list of children's names.
tasks (list): A list of household tasks.
Returns:
dict: A dictionary with kids as keys and their assigned tasks as values.
"""
# Shuffle the tasks list to ensure random assignment
global tasks
random.shuffle(tasks)
# Assign a task to each kid
assigned_tasks = {}
for i, k in enumerate(kids):
assigned_tasks[k] = tasks[i]
tasks = tasks[1:] # task assigned, can be removed
return assigned_tasks
def print_assigned_tasks(assignement):
"""
Print the assigned tasks
"""
for k, task in assignement.items():
print(f"{k}: {task}")
# Assign tasks
task_assignment = assign_tasks()
print("\nAttribution initiale des tâches ménagères...")
print_assigned_tasks(task_assignment)
print("Faut-il changer la tâche d'un enfant? Si oui, saisir le nom de l'enfant")
kid = input("Choix:")
if kid in task_assignment:
task_assignment[kid] = tasks[0] # assign first task
print_assigned_tasks(task_assignment)