-
Notifications
You must be signed in to change notification settings - Fork 0
/
dictionary.py
66 lines (55 loc) · 2.25 KB
/
dictionary.py
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
coursedict = {15112: "Fundamentals of Programming and Computer Science",
18100: "Introduction to Electrical and Computer Engineering",
21259: "Calculus in Three Dimensions",
76101: "Interpretation and Argument",
21120: "Differential and Integral Calculus",
21122: "Integration and Approximation",
33141: "Physics I for Engineering Students"}
userdict = dict()
def addUser(andrewid,username):
userdict[andrewid] = [username]
def getuserInfo(andrewid):
if andrewid in userdict:
return (userdict[andrewid])
else:
return "No user found!"
def studentRole(andrewid, coursecode):
for x in userdict[andrewid][1]:
if x[0] == coursecode:
return x[-1]
def addCourse(andrewid, coursecode,role):
if len(userdict[andrewid]) == 1:
userdict[andrewid].append([(coursecode, coursedict[coursecode],role)])
else:
userdict[andrewid][1].append((coursecode, coursedict[coursecode],role))
return (userdict[andrewid])
def removeCourse(andrewid, coursecode, role):
userdict[andrewid][1].remove((coursecode, coursedict[coursecode],role))
return (userdict[andrewid])
duedict = dict()
def addDue(coursecode, dueDate, homeworkName, handinType):
if not coursecode in duedict:
duedict[coursecode] =[(dueDate, homeworkName, handinType)]
else:
duedict[coursecode].append((dueDate, homeworkName, handinType))
def getDueDate(coursecode):
if coursecode in duedict:
return duedict[coursecode]
else:
return "No Course Found"
def removeDueDate(coursecode, dueDate, homeworkName, handinType):
duedict[coursecode].remove((dueDate, homeworkName, handinType))
addUser("xingshew","Xingsheng Wang")
print(getuserInfo("xingshew"))
addCourse("xingshew",15112,"student")
print(getuserInfo("xingshew"))
addCourse("xingshew",21259,"student")
print(getuserInfo("xingshew"))
addDue(15112, "Sept.23rd","Written1", "recitation")
addDue(15112, "Sept.24rd","Written2", "recitation")
removeCourse("xingshew",21259,"student")
print(getuserInfo("xingshew"))
print(getDueDate(15112))
removeDueDate(15112, "Sept.23rd","Written1", "recitation")
print(getDueDate(15112))
print(studentRole("xingshew",15112))