Question

In: Computer Science

2) Convert this description into a nested conditional: Student has not taken CSC 221 and has...

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)

Solutions

Expert Solution


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

Related Solutions

Now assume that a larger sample of 64 student scores is taken. The sample has a...
Now assume that a larger sample of 64 student scores is taken. The sample has a mean score of 29.5 and a standard deviation of 3.2. If you were to construct a 95% confidence interval for the ACT scores of this high school class, what would the lower boundary of the interval be? You've constructed your confidence interval. Statistically, what does this confidence interval tell us? Can it be used to tell us the true population value of the mean...
Suppose a student who has not taken economics asks you why economists are arguing that we...
Suppose a student who has not taken economics asks you why economists are arguing that we need a “fiscal stimulus package.” How would you answer this question? (better if typed please) Specifically, a) Why are economists arguing that government spending is the solution to this problem? Use Y=C+I+G to answer this question. Why can’t we increase C or I instead of G? b) Why might an economist recommend infrastructure spending over tax cutes? c) Suppose the spending package is 500...
2. A night-club owner has both the student (S) and non-student (NS) customers. The demand for...
2. A night-club owner has both the student (S) and non-student (NS) customers. The demand for drinks by a typical student is QS = 18 - 3P. The demand for drinks by a typical non-student customer is QNS = 10 – 2P. There are equal number of students and non-students. The marginal cost of each drink is $2. If the club owner could easily identify the groups and can serve each group by offering an entry-fee to the club and...
A lumber company has just taken delivery on a shipment of 10,000 2 ✕ 4 boards....
A lumber company has just taken delivery on a shipment of 10,000 2 ✕ 4 boards. Suppose that 10% of these boards (1000) are actually too green to be used in first-quality construction. Two boards are selected at random, one after the other. Let A = {the first board is green} and B = {the second board is green}. (a) Compute P(A), P(B), and P(A ∩ B) (a tree diagram might help). (Round your answer for P(A ∩ B) to...
typical student has a normal distribution with mean of 10 minutes and standard deviation of 2...
typical student has a normal distribution with mean of 10 minutes and standard deviation of 2 minutes to complete a question. The total exam has 80 minutes. how many questions should the exam have so that only 6 in 10,000 students failed the exam? (that is, p(y>80) = 0.0005)
2. The following data represent samples that were taken on 10 separate days. Each day has...
2. The following data represent samples that were taken on 10 separate days. Each day has a varying sample size and the number of defects for the items sampled is listed. We want to see if this process is consistent and in control. Day Sample Size Defects 1 100 6 2 110 4 3 190 10 4 190 7 5 240 15 6 255 8 7 105 3 8 175 6 9 245 22 10 265 27                 a. Find...
2.   A student is taking a multiple-choice test in which each question has five choices. Assume...
2.   A student is taking a multiple-choice test in which each question has five choices. Assume that the student has no knowledge of the correct answers to any of the questions. She has decided on a strategy in which she will place five balls (marked A, B, C, D and E) into a box. She randomly selected one ball for each question and replaces the ball in the box. The marking on the will determine her answer to the question....
when offered terms on 2/10, net 30, Young Brand has always taken the discount, does this...
when offered terms on 2/10, net 30, Young Brand has always taken the discount, does this makes financial sense?
Q. 2. The newly elected municipal chairman has taken over his new office. After reviewing the...
Q. 2. The newly elected municipal chairman has taken over his new office. After reviewing the files and visits in his area, he is of the view that they require major infrastructural changes in his municipality i.e. repairing the sewerage lines, constructions of roads and green belt etc. This would require a huge investment and hence the issuance of municipal bonds. You have been hired as his financial advisor and hence are required to do the following; a) To brief...
Q. 2. The newly elected municipal chairman has taken over his new office. After reviewing the...
Q. 2. The newly elected municipal chairman has taken over his new office. After reviewing the files and visits in his area, he is of the view that they require major infrastructural changes in his municipality i.e. repairing the sewerage lines, constructions of roads and green belt etc. This would require a huge investment and hence the issuance of municipal bonds. You have been hired as his financial advisor and hence are required to do the following; a) To brief...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT