-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathgradetext1.py
More file actions
59 lines (49 loc) · 1.44 KB
/
Copy pathgradetext1.py
File metadata and controls
59 lines (49 loc) · 1.44 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
gt = {} # gt is the acornym for gradetext
def main():
print ('Types of Command lines:\nCommand 1(录入) \nCommand 2(查询) \nCommand 3(删除)')
i = input('Your Command line is:')
i = int(i)
if i == 1:
Command1()
elif i == 2:
Command2()
elif i == 3:
Command3()
else:
print ('You have entered an invalid Command line,please run this programme again.')
def Command1():
while(True):
Name = input('Name:')
Grade = input('Grade:')
try: # Make sure the input is an int or a float
Grade = float(Grade)
gt[Name] = Grade
print ('You have successfully uploaded the file!')
break;
except ValueError:
print ('Please enter an number!')
def Command2():
Name = input('Name:')
if Name in gt:
print ('{}\'s grade is {}'.format(Name,gt[Name]) )
else:
print ('It is not included')
def Command3():
Name = input('Name:')
if Name in gt:
n = input('Do you want to delete it?(Y/N):')
if n == 'Y' or 'y':
del gt[Name]
else:
print ('You have canceled this operation.')
else:
print ('This is not included.')
if __name__ == '__main__':
while(True):
main()
j = input('Do you want to exit?(If so,please enter exit):')
if j == 'exit':
break
print ('Done')
else:
continue