-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathExam grading new.py
55 lines (42 loc) · 1.25 KB
/
Exam grading new.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
#no need for making the file loctaion variable global since only one function is using it
#its better to keep it local under the open file function
file_location="C:/python_tutorials/exam_scores3.txt"
def open_file(file):
file=open(file_location, "r")
data=file.readlines()
return data
def list_sort (d):
list = d
newlist=[i.split('\n', 1)[0] for i in d]
return newlist
names=[i.split(' ,', 1)[0] for i in d]
names=[i.split(',', 1)[0] for i in names]
scores=[i.split(' ,', 3)[0] for i in d]
scores=[i.split(',', 3)[0] for i in names]
keith_data = newlist[0:1]
sophie_data = newlist[1:2]
nelson_data = newlist[2:3]
keith_scores = keith_data[0:2]
# print scores
# print names
# print newlist
print keith_scores
data=open_file(file_location)
list_sort(data)
# def isNumber(s):
# try:
# int(s)
# return True
# except:
# return False
# splitstr = [substr.strip().split(' ') for substr in newlist.split(',')]
# for pair in splitstr:
# if len(pair)>1:
# if isNumber(pair[1]):
# number = int(pair[1])
# else:
# number = "Is not a number"
# else:
# number = "There is no number"
# print(pair[0],number)
# newlist()