In: Computer Science
Write a code on Jupytor notebook:
Pocket 0 is green. For pockets 1 through 10, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets 11 through 18, the odd-numbered pockets are black and the even-numbered pockets are red. For pockets 19 through 28, the odd-numbered pockets are red and the even-numbered pockets are black. For pockets 29 through 36, the odd-numbered pockets are black and the even-numbered pockets are red. Write a program that asks the user to enter a pocket number and displays whether the pocket is green, red, or black. The program should display an error message if the user enters a number that is outside the range of 0 through 36. |
|
3. Check the Baruch/CUNY Pathways requirements for college option – http://www.baruch.cuny.edu/genedreqs/pathwaysatbaruch/pathwaysoptions_baruch.htm. Ask the user the right questions and do the right checks to display the coursework that the user needs to complete. |
4. Calculate BMI for user provided weight and height and display an interpretation of the BMI. |
I have provided well-commented code to all the questions, most of them are if-else blocks and pretty self-explanatory.
1. The well-commented code is as follows:
Sample output:
2.
Sample output for the other case:
3. The code for the following is, please excuse me if i missed some cases, this question was a bit vague. but if you face any issue comment it, i will surely help you.
4.
if the answer helped you, please upvote and in case of any doubts please comment, i will surely help.
Code:
1.
# x is the input integer given by the user
x = int (input("Enter an integer: "))
if (x<0 or x >36) :
print("The number should be in the range 0 to 36")
elif(x==0):
print("The pocket is GREEN")
elif((x>=1 and x<=10)or(x>=19 and x<=28)):
if(x%2):
print("The pocket is RED")
else :
print("The pocket is BLACK")
else: # the remaining numbers will be between (11 to 18) and (29 to
36) in this else condition
if(x%2):
print("The pocket is BLACK")
else:
print("The pocket is RED")
2.
# credit stores the total credit scored by the student
# gpa variable stores the overall BAruch GPA of the student
credit = int(input("Enter the number of credits that you have
completed: "))
gpa = float(input("Enter your overall GPA: "))
if(credit>=45 and gpa>=2.25):
# condition that student's credit is greater than equal to 45 and
overall gpa>= 2.25
print("Eligible to enter Zicklin")
else:
print("Not Eligible to enter Zicklin")
3.
# Select the type of oursework the student has completed at
another institution.
print("Which of the following are you?")
print("1. Students transferring from an Associate Degree Program to
Baruch")
print("2. Students transferring from a CUNY Bachelor’s Degree
Program to Baruch")
print("3. Students transferring from a Non-CUNY Bachelor’s Degree
Program to Baruch")
print("4. Second Bachelor’s Degree Students")
print("5. Students who transfer multiple times")
userType = int(input())
# take the user COTP score
COTP = int(input("Enter your COTP credits: "))
# For every type of user we create a seperate if-else
block
if userType == 1:
# the first user can be of three types
print("Which of the following categories are you from?")
print("1. Earned Associate Degree")
print("2. Earned More than 30 credits")
print("3. Earned 30 or Fewer credits")
# we select the type of user amongst the three categories
category = int(input())
# if the user has enough credits then we show he is eligible
# otherwise we show the extra credits that he needs
# and we do the same for all other types of previous
education
if category == 1:
if(COTP >= 6):
print("You are eligible")
else:
print(f"You need {6-COTP} more COTP credit")
elif category == 2:
if(COTP >= 9):
print("You are eligible")
else:
print(f"You need {9-COTP} more COTP credit")
elif category == 3:
if(COTP >= 12):
print("You are eligible")
else:
print(f"You need {12-COTP} more COTP credit")
elif userType == 2:
if(COTP >= 12):
print("You are eligible")
else:
print(f"You need {12-COTP} more COTP credit")
elif userType == 3:
if(COTP >= 12):
print("You are eligible")
else:
print(f"You need {12-COTP} more COTP credit")
elif userType == 4:
print("You are eligible")
else:
print("Which of the following categories are you from?")
print("1. Began college in associate program")
print("2. Began college in baccalaureate program")
category = int(input())
if category == 1:
if(COTP >= 6):
print("You are eligible")
else:
print(f"You need {6-COTP} more COTP credit")
elif category == 2:
if(COTP >= 12):
print("You are eligible")
else:
print(f"You need {12-COTP} more COTP credit")
4.
height = float(input("Enter your height in centimeter"))
weight = float(input("Enter your weight in kilograms"))
# converting height into meters from centimeters
height=height/100
# bmi is the variable to store the calculated BMI of the
user
bmi = weight/(height*height) # metric BMI calculation formula
print("User's BMI is ", bmi)
print("According to your BMI:- ")
if(bmi<18.5):
print("You are Underweight")
elif(bmi>=18.5 and bmi<25.0):
print("You are Healthy")
elif(bmi>=25.0 and bmi<30.0):
print("You are Overweight")
else:
print("You are Obese")