7.5 Code practice Plz answer ASAP

7.5 Code Practice Plz Answer ASAP

Answers

Answer 1

def calculate_GPA(grade, weight):

   grades = {"A": 4, "B": 3, "C": 2, "D": 1, "F": 0}

   if weight == 0:

       return grades[grade]

   else:

       return grades[grade] + 1

classes = int(input("How many Classes are you taking? "))

total = 0

for x in range(classes):

   letter = input("Enter your Letter Grade: ")

   user_weight = int(input("Is it weighted? (1 = yes) "))

   grade = calculate_GPA(letter, user_weight)

   total += grade

   print("Your GPA score is: ", grade)

print("Your weighted GPA is a",(total/classes))

I wrote my code in python 3.8. I was able to replicate the output in your picture exactly. If you need me to make any changes, I'll do my best.

Answer 2

The function is an illustration of for loops

For loops are used to perform repetitive operations; just like the while loop

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

#This defines the studentGPA function

def studentGPA(grade, weight):

   #This initializes a dictionary for all grades

   allGrade = {"A": 4, "B": 3, "C": 2, "D": 1, "F": 0}

   #This sets the return grade to 0

   retValue = 0

   #If the grade is valid

   if grade in allGrade:

       #If the weight is 0

       if weight == 0:

           #Then score is not graded

           retValue = allGrade[grade]

       #If otherwise

       else:

           #This adds 1 to the return grade

           retValue = allGrade[grade]+1

   #This returns the grade point

   return retValue

#The main begins here    

#This gets the number of classes

klass = int(input("How many Classes are you taking? "))

#This initializes the total grade to 0

total = 0

#This following is repeated for each class

for x in range(klass):

   #This gets input for the letter grade

   letterGrade = input("Enter your Letter Grade: ")

   #This gets input for the weight

   weight = int(input("Is it weighted? (1 = yes) "))

   #This gets the corresponding grade

   grade = studentGPA(letterGrade, weight)

   #This prints the grade point

   print("Your GPA score is: ", grade)

   #This calculates the total grade

   total += grade

#This calculates the GPA

GPA = total/klass

#This prints the GPA

print("Your weighted GPA is a",GPA)

Read more about for loop at:

https://brainly.com/question/12736327


Related Questions

KAPWING Video Editing Software allows you to use existing You Tube Videos in your design.

Answers

Answer:

Yea it should, it depends are you using a phone or a PC? because most of the time internally built in editing software on computers is better.

Other Questions
The sides of three squares can be used to form triangles. The areas of the squares thatform right triangles have a special relationship. The triangle formed in the drawing below isa right triangle.What is the value of x, the side length of Square 2? COMPLETE: Create and Complete the following table in a textbox. You can copy and paste this table or construct a new one.Template (anti-sense) strand |___|___|___|GGG|___|Non-template strand |TAC|___|___|___|___|mRNA |___|___|___|___|CCU|tRNA |___|UCH|___|___|___|Amino Acids |___|___| Leu |___|___|The faster the better! The explanation isn't necessary if you're confident in the answer. THANK YOU! ___is a process that tells cells to stop dividing if they touch each other. As an estimation we are told 5 miles is 8 km.Convert 19.2 miles to km. As Islam and Christianity spread through Africa, whch of the following were examples oftheir imnpact? Select all that apply. How much time has passed?Start time: 4:45 a.m. End time: 7:25 a.m. If an insurance policy covers individual losses up to $10,000 and has a deductible of$500, the insured will be paid how much in the event of a covered loss of $5,000? HELP ME PLZZZ This is the only table I don't know, In which choice do all three points lie on the same straight line?A. (0,0) (1, 1) (2, 4)B. (5, 1) (-3,0) (-1,2)C. (2, 10) (4.9) (5,8)D. (0.1) (2,3) (4,5) Pls help need answers fast Write an equation to find the value of x so that each pair of polygons has the same perimeter. Then solve In a bag, you have a strip of paper with the numbers 1-10 written on the strips. If one strip of paper is pulled from the bag and then replaced, what is the probability of the following events: pick a odd number and then a even number.A: 1/2B: 1/4C: 1/5D: 1/25 What might be an example of corporate social responsibility Can someone please help me with this Ill give them extra points and brilliant it actually has to be an answer though If x = 3, evaluate x + 7 QUICK!! TEN POINTS!! BRAINLIEST FOR WHOEVER GETS IT RIGHT!! What are the coordinates of point S? (-3/41/2) (-1/2,3/4) (1/2,3/4) (3/4,1/2) Why is the growth of cities important for the growth of civilization? How do you further solve this? What are two characteristics of expository text? A sandbox is located at (-8, -3). How many UNITS apart on the coordinate plane are the locations of the swing set and the sandbox?