In: Computer Science
2) Convert this description into a nested conditional:
Student has not taken CSC 221 and has not taken MAT 104, enroll
in MAT 104
Call enrollMeIn("MAT104")
Student has not taken CSC 221 and has taken MAT 104, enroll in CSC
221
Call enrollMeIn("CSC221")
Student has taken CSC 221 and has not taken CSC 231, enroll in CSC
231
Call enrollMeIn("CSC231")
Student has taken CSC 221 and CSC 231, enroll in CSC 223
Call enrollMeIn("CSC223")
You need to use a nested conditional. There are *no* and/or/not keywords. Just if statements with conditions (<, >, ==, etc).
3) Convert the description in (2) into a chained conditional. Now you may use and/or/not.
4) Convert this for loop into a while loop:
for i in range(1, 15, 2): print(i)
PLEASE GIVE IT A THUMBS UP, I SERIOUSLY NEED ONE, IF YOU
NEED ANY MODIFICATION THEN LET ME KNOW, I WILL DO IT FOR YOU
AS I DONE MOST OF YOUR ANSWERS, THOUGH WE ARE ONLY ALLOWED TO
ATTEMPT ONE ANSWER OR FOUR SUB PARTS, PLEASE GIVE IT A THUMBS
UP
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
2)
# flag1 is for CSC221
flag1=0
# flag2 is for MAT104
flag2=0
# flag3 is for CSC231
flag3=0
# Assuming taken as the list containing the courses student has taken
for i in taken:
#Change the corresponding flag to 1 if the course is taken
if i=="CSC 221":
flag1=1
if i=="MAT 104":
flag2=1
if i=="CSC 231":
flag3=1
#If CSC 221 is not taken
if flag1==0:
#MAT 104 is not taken
if flag2==0:
enrollMeln("MAT104")
#MAT 104 is taken
else:
enrollMeln("CSC221")
#If CSC 221 is taken
else:
#If CSC 231 is not taken
if flag3==0:
enrollMeln("CSC231")
#If CSC 231 is taken
else:
enrollMeln("CSC223")
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
3)
# flag1 is for CSC221
flag1 = 0
# flag2 is for MAT104
flag2 = 0
# flag3 is for CSC231
flag3 = 0
# Assuming taken as the list containing the courses student has taken
for i in taken:
# Change the corresponding flag to 1 if the course is taken
if i == "CSC 221":
flag1 = 1
if i == "MAT 104":
flag2 = 1
if i == "CSC 231":
flag3 = 1
# If CSC 221 is not taken and MAT 104 is not taken
if flag1 == 0 and flag2 == 0:
enrollMeln("MAT104")
# If CSC 221 is not taken and MAT 104 is taken
elif flag1 == 0 and flag2 == 1:
enrollMeln("CSC221")
# If CSC 221 is taken and CSC 231 is not taken
elif flag1 == 1 and flag3 == 0:
enrollMeln("CSC231")
# If CSC 221 is taken and CSC 231 is taken
elif flag1 == 1 and flag3 == 1:
enrollMeln("CSC223")
------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
4)
i=1
while(i<15):
print(i)
i+=2