-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathp_exer4.py
103 lines (90 loc) · 3.99 KB
/
p_exer4.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
class p_exer4():
def __init__(self):
self.items=[]
self.subs=['OOP','APPDEV', 'PE3', 'SOFTENG', 'NET1', 'MAEL2', 'DISTRU2', 'READPHILHIS']
def push (self,item):
self.items.insert(0,item)
def remove(self):
self.items.remove(enrolled)
def isEmpty (self):
return self.items==[]
n=p_exer4()
name =str(input("Enter your name: "))
print('---------------------------------')
print("Welcome",name)
print('Current Units Enrolled:',len(n.items)*3)
#print(n.subs)
while True:
if len(n.items)*3<24:
try:
print('---------------------------------')
print("MAIN CHOICES\n")
print("[1]ADD SUBJECT\n[2]DROP SUBJECT\n[3]PRINT\n[4]EXIT")
print('---------------------------------')
choice =int(input("Enter your choice: "))
if choice == 1: #ADD
print('----List of Subjects For 2nd Yr 1st Sem----')
for x in n.subs:
print('|\t',x)
print('------------------------------------------')
add = str(input('ADD SUBJECT: ')).upper()
if add in n.subs:
if add not in n.items:
n.push(add)
print('Subject Succesfull Added!!')
print('Current Units Enrolled:',len(n.items)*3)
else:
print("already enrolled")
else:
print('not in list of subs for 2nd yr 1st sem' )
elif choice == 2: #DROP
if n.isEmpty():
print("------No Enrolled Subjects------")
print('Current Units Enrolled:',len(n.items)*3)
continue
else:
print('---SUBJECTS CURRENTLY ENROLLED---')
count =0
for x in n.items:
count +=1
print('[',count,']',x)
print('Current Units Enrolled:',len(n.items)*3)
print('---------------------------------')
enrolled = int(input('Select which subjects you want to drop: '))
n.items.pop(enrolled-1)
print('Current Units Enrolled:',len(n.items)*3)
elif choice == 3: #PRINT
if n.isEmpty():
print("------No Enrolled Subjects------")
print('Current Units Enrolled:',len(n.items)*3)
continue
else:
print('---SUBJECTS CURRENTLY ENROLLED---')
for x in n.items:
print('|\t',x)
print('| Current Units Enrolled:',len(n.items)*3)
print('---------------------------------')
elif choice == 4: #EXIT
val = input ("Are you sure you want to quit [Y/N]?")
if val == "y" or val =="Y":
print('Goodbye!',name)
print ("---- Program terminated ----")
break
elif val =="N" or val =="n":
continue
else:
print("---- Invalid Input ----\n")
except IndexError:
print("*** Invalid Input Try Again ***")
continue
except ValueError:
print("*** Invalid Input Try Again ***")
continue
else:
print('---------------------------------')
print("You have exceeded the number of units to be enrolled")
break
#LANCE DENZEL RAZON
#BSCS-201
#7OOP
#09-03-19