you will take the output from the first task and write an algorithm and matching code to perform the second task, which is to calculate and print out the GPA rounded to 2 decimal places.

Database System Concepts
7th Edition
ISBN:9780078022159
Author:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Chapter1: Introduction
Section: Chapter Questions
Problem 1PE
icon
Related questions
Question

you will take the output from the first task and write an algorithm and matching code to perform the second task, which is to calculate and print out the GPA rounded to 2 decimal places. So, for the test input

[1, 4, 3, 3, 2, 1, 3, 0, 3, 2, 2]

The output would be 2.18

output from 1st task is in photo

Identify which pattern or patterns could best be applied to the solution of the second task. State clearly the name of the pattern and the pattern number, for example “List generation Pattern 2.2

Pattern 4.1 Formula

Pattern 4.2 Case analysis (two cases))

Pattern 4.3 Case analysis (multiple cases)

Pattern 4.4 Case analysis (nested cases)

Pattern 4.5 Sequence generation

Pattern 2.2 List generation

Pattern 2.3 List filtering

Pattern 2.4 List transformation

Pattern 2.5 Reduction: counting

Pattern 2.6 Reduction: aggregation

Pattern 2.7 Reduction: find value

Pattern 2.8 Reduction: find best value

Pattern 2.9 Reduction: version 3 find position of first best value

choice = 'Y'
while choice != 'N':
num_of_grades = int(input(
"Enter number of grades you want to enter: ")) # asking user number of grades including
# academic and non-academic
grades = [] # list to store entered grades
grades_numeric_value = [] # list to store the numeric value of grades
#looping and storing the input and its numeric value
for i in range(num_of_grades):
grades. append(input("Grade: "))
# different cases of Grades
if grades[i] == 'A':
grades_numeric_value.append(4)
elif grades[i] == 'B':
grades_numeric_value.append(3)
elif grades[i] == 'C':
grades_numeric_value.append(2)
elif grades[i] == 'D':
grades_numeric_value.append(1)
elif grades[i] == 'F':
grades_numeric_value.append(0)
#we have not written case for W grade because it is non-academic grade
#appending 'C' as according to id, first digit is '1' which is odd so, as per question add 'C'
grades. append('C')
grades_numeric_value.append(2) # adding numeric value
# calculating total grade point using sum function
total_grade_point = sum(grades_numeric_value)
gpa = total_grade_point / len(grades_numeric_value) # calculating GPA by dividing total with num of
grades
print("Grades: ", grades) # displaying all grades
print("Grade points: ", grades_numeric_value) # displaying grade point of academic courses
print("Your total GPA is : {:.2f}".format(gpa)) # printing GPA
print("Do you want to calculate another GPA? (Y = yes / N = no)") # asking user if he wants to calculate
again
choice = input() # storing input
print("Thank You!") # greeting
Transcribed Image Text:choice = 'Y' while choice != 'N': num_of_grades = int(input( "Enter number of grades you want to enter: ")) # asking user number of grades including # academic and non-academic grades = [] # list to store entered grades grades_numeric_value = [] # list to store the numeric value of grades #looping and storing the input and its numeric value for i in range(num_of_grades): grades. append(input("Grade: ")) # different cases of Grades if grades[i] == 'A': grades_numeric_value.append(4) elif grades[i] == 'B': grades_numeric_value.append(3) elif grades[i] == 'C': grades_numeric_value.append(2) elif grades[i] == 'D': grades_numeric_value.append(1) elif grades[i] == 'F': grades_numeric_value.append(0) #we have not written case for W grade because it is non-academic grade #appending 'C' as according to id, first digit is '1' which is odd so, as per question add 'C' grades. append('C') grades_numeric_value.append(2) # adding numeric value # calculating total grade point using sum function total_grade_point = sum(grades_numeric_value) gpa = total_grade_point / len(grades_numeric_value) # calculating GPA by dividing total with num of grades print("Grades: ", grades) # displaying all grades print("Grade points: ", grades_numeric_value) # displaying grade point of academic courses print("Your total GPA is : {:.2f}".format(gpa)) # printing GPA print("Do you want to calculate another GPA? (Y = yes / N = no)") # asking user if he wants to calculate again choice = input() # storing input print("Thank You!") # greeting
Expert Solution
steps

Step by step

Solved in 2 steps with 4 images

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

experts need to read the question correctly you are not been asked for code or an algorithm you are been asked:

Identify which pattern or patterns could best be applied to the solution of the second task. State clearly the name of the pattern and the pattern number, for example “List generation Pattern 2.2

Pattern 4.1 Formula

Pattern 4.2 Case analysis (two cases))

Pattern 4.3 Case analysis (multiple cases)

Pattern 4.4 Case analysis (nested cases)

Pattern 4.5 Sequence generation

Pattern 2.2 List generation

Pattern 2.3 List filtering

Pattern 2.4 List transformation

Pattern 2.5 Reduction: counting

Pattern 2.6 Reduction: aggregation

Pattern 2.7 Reduction: find value

Pattern 2.8 Reduction: find best value

Pattern 2.9 Reduction: version 3 find position of first best value

please read correctly before you answer intead of wasting peoples questions

Solution
Bartleby Expert
SEE SOLUTION
Knowledge Booster
Random Class and its operations
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
Recommended textbooks for you
Database System Concepts
Database System Concepts
Computer Science
ISBN:
9780078022159
Author:
Abraham Silberschatz Professor, Henry F. Korth, S. Sudarshan
Publisher:
McGraw-Hill Education
Starting Out with Python (4th Edition)
Starting Out with Python (4th Edition)
Computer Science
ISBN:
9780134444321
Author:
Tony Gaddis
Publisher:
PEARSON
Digital Fundamentals (11th Edition)
Digital Fundamentals (11th Edition)
Computer Science
ISBN:
9780132737968
Author:
Thomas L. Floyd
Publisher:
PEARSON
C How to Program (8th Edition)
C How to Program (8th Edition)
Computer Science
ISBN:
9780133976892
Author:
Paul J. Deitel, Harvey Deitel
Publisher:
PEARSON
Database Systems: Design, Implementation, & Manag…
Database Systems: Design, Implementation, & Manag…
Computer Science
ISBN:
9781337627900
Author:
Carlos Coronel, Steven Morris
Publisher:
Cengage Learning
Programmable Logic Controllers
Programmable Logic Controllers
Computer Science
ISBN:
9780073373843
Author:
Frank D. Petruzella
Publisher:
McGraw-Hill Education