-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathStudentInfo.py
125 lines (91 loc) · 2.63 KB
/
StudentInfo.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
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
print("*********Program for Student Information*********")
D = dict()
n = int(input('How many student record you want to store?? '))
# Add student information
# to the dictionary
for i in range(0, n):
x, y = input(
"Enter the complete name (First and last name) of student: ").split()
z = input("Enter contact number: ")
m = input('Enter Marks: ')
D[x, y] = (z, m)
# define a function for shorting
# names based on first name
def sort():
ls = list()
# fetch key and value using
# items() method
for sname, details in D.items():
# store key parts as an tuple
tup = (sname[0], sname[1])
# add tuple to the list
ls.append(tup)
# sort the final list of tuples
ls = sorted(ls)
for i in ls:
# print first name and second name
print(i[0], i[1])
return
# define a function for
# finding the minimum marks
# in stored data
def minmarks():
ls = list()
# fetch key and value using
# items() methods
for sname, details in D.items():
# add details second element
# (marks) to the list
ls.append(details[1])
# sort the list elemnts
ls = sorted(ls)
print("Minimum marks: ", min(ls))
return
# define a function for searching
# student contact number
def searchdetail(fname):
ls = list()
for sname, details in D.items():
tup = (sname, details)
ls.append(tup)
for i in ls:
if i[0][0] == fname:
print(i[1][0])
return
# define a funtion for
# asking the options
def option():
choice = int(input('Enter the operation detail: \n \
1: Sorting using first name \n \
2: Finding Minimum marks \n \
3: Search contact number using first name: \n \
4: Exit\n \
Option: '))
if choice == 1:
# finction call
sort()
print('Want to perform some other operation??? Y or N: ')
inp = input()
if inp == 'Y':
option()
# exit finction call
exit()
elif choice == 2:
minmarks()
print('Want to perform some other operation??? Y or N: ')
inp = input()
if inp == 'Y':
option()
exit()
elif choice == 3:
first = input('Enter first name of student: ')
searchdetail(first)
print('Want to perform some other operation??? Y or N: ')
inp = input()
if inp == 'Y':
option()
exit()
else:
print('Thanks for executing me!!!!')
exit()
option()