In: Computer Science
Write a program in Python jupyter notebook for
following:
Part1:
Course grade calculation: Course grades for CIS 1100 are calculated
based on two assignments, a midterm exam, and a final exam. Here
are the weights of these.
Assignments 25%
Midterm exam 35%
Final exam 40%
Ask the user for the scores they received for the two assignments, midterm exam, and the final exam. Then calculate and display their total weighted score they received for the course.
Based on the weighted score, calculate and display the letter grade. Here are the grading guidelines:
Score >=90: A
Score >=80: B
Score >=70: C
Score <70: F
Part 2:
The colors red, blue, and yellow are known as the primary colors because they cannot be made by mixing other colors. When you mix two primary colors, you get a secondary color, as shown here:
When you mix red and blue, you get purple.
When you mix red and yellow, you get orange.
When you mix blue and yellow, you get green.
Design a program that prompts the user to enter the names of two primary colors to mix. If the user enters anything other than “red,” “blue,” or “yellow,” the program should display an error message. Otherwise, the program should display the name of the secondary color that results.
# part 1
# ask user for the inputs in numbers
assgn = int(input("Enter the marks in your assignments :"))
midtrm = int(input("Enter the marks in your midterm :"))
final = int(input("Enter the marks in your Finals :"))
# calculating the total marks achieved
total_score = int( assgn * (25/100) + midtrm * (35/100) + final *
(40/100))
# printing the Grades
if total_score >= 90:
print("A Grade")
elif total_score >= 80 and < 90:
print("B Grade")
elif total_score >= 70 and < 80:
print("C Grade")
else:
print("F ")
####################################################
# part 2
# primary colors
colors = ["red","blue" ,"yellow"]
# ask the user for colors
color1 = input("Enter first color :").lower() # lower() is to
convert into lower case
color2 = input("Enter second color :").lower()
if color1 or color2 not in colors:
print("Error. Please enter primary colors only")
else:
if color1 == "red" and color2 == "blue":
print("purple")
elif color1 == "red" and color2 == "yellow":
print("orange")
elif color1 =="blue" and color2 =="yellow":
print("green")