7.4 Code Practice: Question 2
Adjust the code you wrote for the last problem to allow for weighted classes. Add a parameter weighted ( 1 = yes, 0 = no) and then return the correct number for the GPA. Weighted classes get one extra point on the GPA value.

I could really use some help on this and 7.5 (I’ll ask that question for 7.5 later)

7.4 Code Practice: Question 2Adjust The Code You Wrote For The Last Problem To Allow For Weighted Classes.

Answers

Answer 1

def GPAcalc(grade, weighted):

   grade = grade.lower()

   dictionary = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}

   if weighted == 1 and grade in dictionary:

       return "Your GPA score is: "+str(dictionary[grade] + 1)

   elif weighted == 0 and grade in dictionary:

       return "Your GPA score is : "+str(dictionary[grade])

   else:

       return "Invalid"

print(GPAcalc(input("Input a letter grade: "), int(input("Is it weigthed? (1= yes, 0= no)"))))

I modified the code a bit to cut down on the use of if and elif statements. If you need me to change it, I will. Best of luck.

Answer 2

The program is an illustration of conditional statements.

Conditional statements are statements whose execution is dependent on its truth value.

The program in Python, where comments are used to explain each line is as follows:

#This initializes the dictionary

dict = {"a": 4, "b": 3, "c": 2, "d": 1, "f": 0}

#This gets input for grade

grade = input().lower()

#This gets input for the weighted average

weighted = int(input())

#If the weighted average is 1, and the grade is in the dictionary

if weighted == 1 and grade in dictionary:

   #This prints the GPA score

   print("Your GPA score is: "+str(dict[grade] + 1))

#If the weighted average is 0, and the grade is in the dictionary

elif weighted == 0 and grade in dictionary:

   #This prints the GPA score

   print("Your GPA score is : "+str(dict[grade]))

#Otherwise

else:

   #The grade is invalid

   print("Invalid")

Read more about similar programs at:

https://brainly.com/question/19241597


Related Questions

DO NOW
1. What are the 4 things that make a computer a
computer?

Answers

Answer:

CPU, GPU, Hard drive, Video Card

Explanation:

What are the requirements to access email on the web?

A. a webmail provider's URL and a password
B. a webmail provider's URL a username and a password
C. a credit or debit card, a username, and a password
D. an email server ID and a password

Answers

Answer:

it's B

Explanation:

You need to have a provider (such as outlook) and a username/password

It’s either A or D u Choose now
Other Questions
Juveniles right to proper placement could best be described as the right to be placedby themselves.separately from adult offenders.under parental or guardian supervision.with other juveniles. What is the equation of this line?y=1/2x-3y=-1/2x-3y=-2x-3y=2x-3 what happened before the murder in tell tale heart Which of the following might mean that Stephanie is tired? The Opium wars were ended by what treaty SOMEONE PLEASE HELP everything reminds me of him Very hard QUestion!!!!................... Whos Anthony Davis Carlos picked one of four equations in the table to solve. Carlos correctly solved the equation he chose. His answer was x = 5.Equation 1 6x + 40 = 82Equation 2 12x- 1 = 2Equation 3 2x + 21 = 31Equation 4 18x+ 9 = 13Which equation did Carlos choose to solve? What is a living thing? Which molecule is solid at Room temperature? What is a hallmark of essembly lines in Henry fords time? what are the similarities and differences between respiration and photosynthesis?? which equation represents the line that passes through points (5,4) and (-5,0) The process of generating electricity from dams and nuclear power plants is very different, but some of the energy transformations are the same. Which energy transformations occur in both dams and nuclear power plants? Check all that apply. Why might some civilizations not have been part of the Neolithic Revolution? For each turn of the Krebs cycle, how many ATP, NADH, and FADH2 are produced, respectively?A. 2, 4, 2B. 3, 2, 3C. 2, 6, 2D. 1, 3, 1 Please answer the following essay question:Define advertising and explain its key components. Discuss the roles and functions of advertising.Answer in paragraph form using 5-7 complete sentences How many integers between 2020 and 2400 have four distinct digits arranged in increasingorder? (For example 2957 is one such integer)(B) 10(C) 15(D) 21e 28 if y varies directly with x and x increases by 2 , is it possible to determine by how much y increases or decreases . yes or no and why