/
Define a class student which must have properties like id, name, age, marks for maths, science, English, total, percentage, status, grade . Make two function one for inputting data
152 lines (141 loc) · 3.06 KB
/
Define a class student which must have properties like id, name, age, marks for maths, science, English, total, percentage, status, grade . Make two function one for inputting data
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
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
# list containing some elements
lst=['laptop', 'wireless mouse', 'wireless keyboard', 'headphone']
def pushData():
data=input('Enter the data to insert: ')
lst.append(data)
print(f'{data} inserted successfully..')
display()
def popData():
if len(lst) == 0:
print('List is empty.')
else:
data=lst.pop(len(lst)-1)
print(f'{data} popped successfully..')
display()
def enqueue():
pushData()
def dequeue():
if len(lst)==0:
print('List is empty.')
else:
data=lst.pop(0)
print(f'{data} deleted successfully..')
display()
def display():
print(lst)
print()
if __name__ == '__main__':
while True:
print('1. Push Data')
print('2. Pop Data')
print('3. Enqueue')
print('4. Dequeue')
print('5. Display')
print('6. Exit')
ch=int(input('Enter the choice: '))
if ch==1:
pushData()
elif ch==2:
popData()
elif ch==3:
enqueue()
elif ch==4:
dequeue()
elif ch==5:
display()
elif ch==6:
exit(0)
print()
# Using pointers
#
# # size
# lst=[None] * 100
#
# lst[0]='laptop'
# lst[1]='wireless mouse'
# lst[2]='wireless keyboard'
# lst[3]='headphone'
# top=3
# front, rear= 0, 3
#
# def addData():
# global top
#
# data=input('Enter the data to insert: ')
# top=top+1
# lst[top]=data
#
# print(f'{data} inserted successfully..')
# display(0, top)
#
# def popData():
# global top
#
# if top==-1:
# print('List is empty.')
# else:
# data=lst[top]
# top=top-1
# print(f'{data} popped successfully..')
# display(0, top)
#
# def enqueue():
# global rear, front
#
# data = input('Enter the data to insert: ')
# rear = rear + 1
# lst[rear] = data
#
# print(f'{data} inserted successfully..')
# display(front, rear)
#
# def dequeue():
# global front, rear
#
# if front>rear:
# print('List is empty.')
# else:
# data=lst[front]
# front=front+1
# print(f'{data} deleted successfully..')
# display(front, rear)
#
# def display(start, end):
# print(lst[start:end+1])
# print()
#
# if __name__ == '__main__':
#
# while True:
# print('1. Push Data')
# print('2. Pop Data')
# print('3. Enqueue')
# print('4. Deque')
# print('5. Display')
# print('6. Exit')
#
# ch=int(input('Enter the choice: '))
#
# if ch==1:
# addData()
# elif ch==2:
# popData()
# elif ch==3:
# enqueue()
# elif ch==4:
# dequeue()
# elif ch==5:
# print('1. Display with respect to Stack')
# print('2. Display with respect to Queue')
# ch1=int(input('Enter the choice'))
#
# if ch1==1:
# display(0, top)
# else:
# display(front, rear)
#
# elif ch==6:
# exit(0)
#
# print()
#