-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunction global 2 .py
More file actions
49 lines (40 loc) · 973 Bytes
/
Copy pathfunction global 2 .py
File metadata and controls
49 lines (40 loc) · 973 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
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
key= ' '
ans =' '
def calculate(key,ans):
i=count=0
for c1 in key:
if c1==ans[i]:
count+=1
i+=1
return count*10
def inp():
global key
key=input("Enter answer key: ")
dict={}
scores=[]
sum=0
for number in range(1,4):
name=input("Enter name: ")
last=input("Enter last name: ")
answers=input("Enter answers: ")
lst=[]
lst.append(name)
lst.append(last)
score=calculate(key,answers)
tup=tuple(lst)
dict[tup]=score
sum+=score
scores.append(score)
avg=sum/len(dict)
return(dict,scores,avg)
d,s,av=inp()
print(d)
print("Average: ",av)
print("Students above average ")
for a in d.keys():
if d[a]>=av:
print("Name: ",a[1]+','+a[0][0]+'.',"Score: ",d[a])
st=input("Who are you searching for? ")
for a in d.keys():
if st in a:
print(a[0],a[1],"received ",d[a])