-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathpair_programming.py
More file actions
76 lines (57 loc) · 2.01 KB
/
pair_programming.py
File metadata and controls
76 lines (57 loc) · 2.01 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
68
69
70
71
72
73
74
75
76
#!/usr/bin/env python3
"""
file: pair_programming.py
Pair programming code for in-class activities.
Randomly assigns partners to tables and does the pair-programming timing.
author: M.P. Kuchera
date: 29 Jan 2018
edited: 16 July 2018
"""
import numpy as np
import time
import os
import sys
# global variables
students = ["Michelle Kuchera", "Jack Taylor", "Anthony Kuchera", "Maggie Perry", \
"Matt Perry", "Zuri Brandt", "Mark Newman", "Paul Tipler", "Sam Tabor", \
"Ernest Hemmingway"]
def partner_assignments():
print("there are", len(students), "students in the class. They are:")
for student in students:
print(student, end=", ")
students_per_group = 2
num_groups = len(students) / students_per_group
print("\n\nThere are",num_groups, "groups in the class.")
np.random.shuffle(students)
for i in range(0,int(num_groups)):
print("\nTable ",i+1,": ",students[i*students_per_group],"and" ,students[i*students_per_group+1],end=" ")
# print(students[i*students_per_group],"and " ,students[i*students_per_group+1] )
if(len(students)%students_per_group != 0):
print("and" ,students[-1])
def coding_time():
input("\n\nPress `Enter` when ready to start pair programming:")
inp_min = input('How much time do the students have in minutes? ')
minutes = float(inp_min)
tot_time = minutes * 60
inp_turn = input('How much time is one turn in minutes?')
one_turn = float(inp_turn)*60
print("\nStart coding!")
os.system('say "Start Coding!"')
for t in range(0,int(tot_time/one_turn)):
time.sleep(one_turn)
print("Time to switch roles!")
sys.stdout.flush()
os.system('say "Switch roles!"')
time.sleep(one_turn)
print("Time is up")
sys.stdout.flush()
os.system('say Time is up. ')
# main function
def main():
# set partners and tables
partner_assignments()
#
coding_time()
# run main() function iff we are executing THIS file.
if __name__ == "__main__":
main()