forked from psounis/python
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexercise4.py
More file actions
33 lines (28 loc) · 929 Bytes
/
exercise4.py
File metadata and controls
33 lines (28 loc) · 929 Bytes
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
from random import seed
from random import randrange
from datetime import datetime # all 3 at the beginning
seed(datetime.now()) # once, before randint call
N = 30
pupils = set()
for number in range(N):
pupils.add("pupil" + str(number))
list_pupils = list(pupils)
math_teams = set()
for _ in range(N//2):
pos1 = randrange(0, len(list_pupils))
pupil1 = list_pupils.pop(pos1)
pos2 = randrange(0, len(list_pupils))
pupil2 = list_pupils.pop(pos2)
team = (pupil1, pupil2)
math_teams.add(team)
print("Math teams: " + str(math_teams))
list_pupils = list(pupils)
geography_teams = set()
for _ in range(N//2):
pos1 = randrange(0, len(list_pupils))
pupil1 = list_pupils.pop(pos1)
pos2 = randrange(0, len(list_pupils))
pupil2 = list_pupils.pop(pos2)
team = (pupil1, pupil2)
geography_teams.add(team)
print("Geography teams: " + str(geography_teams))