Annotate following code.
def QualityPointCalculator(qualPnts, crdts):
if crdts > 0:
return qualPnts/crdts
return 0
def convertGrade(grade):
if grade == "A":
return 4.00
elif grade == "A-":
return 3.70
elif grade == "B+":
return 3.30
elif grade == "B":
return 3.00
elif grade == "B-":
return 2.70
elif grade == "C+":
return 2.30
elif grade == "C":
return 2.00
elif grade == "C-":
return 1.70
elif grade == "D+":
return 1.30
elif grade == "D":
return 1.00
else:
return 0.00
def calcQualPnts(pnts, crdts):
return pnts*crdts
if __name__ == '__main__':
quality_points = []
course_names = []
grades = []
credits = []
final_gpa = 0.0
semester_gpa = 0.0
final_total = 0.0
howMany = 0
print('GRADE & QUALITY NUMERICAL POINTS')
choice = input('Would you like to calculate your GPA for a term? Enter Y/N: ')
while choice.upper()[0] == 'Y':
howMany = int(input('How many courses did you take in the term: '))
for i in range(howMany):
course_name = input('Enter the name of course '+str(i+1)+': ')
course_names.append(course_name)
credit = float(input('Enter the number of credits associated with that course: '))
credits.append(credit)
grade = input('Enter the grade for the course: ')
grade = grade.upper()
grades.append(grade)
quality_point = calcQualPnts(convertGrade(grade),credit)
quality_points.append(quality_point)
semester_gpa += quality_point
print('\nThis term you have earned:')
print('%-15s%-10s%-10s%-15s' %('Course','Credits','Grade','Quality Points'))
for i in range(howMany):
print('%-15s%-10d%-10s%-15.1f' %(course_names[i],credits[i],grades[i],quality_points[i]))
print('Total earned credits this term: %d' %(sum(credits)))
gpa = QualityPointCalculator(sum(quality_points),sum(credits))
print('You earned %.1f quality points and a GPA of %.2f for the term.' %(sum(quality_points),gpa))
final_gpa += semester_gpa
final_total += sum(credits)
choice = input("\nWould you like to calculate another term's GPA? Enter Y/N: ")
quality_points = []
course_names = []
grades = []
credits = []
semester_gpa = 0
print('\nYour overall earned credits: %d '%final_total)
gpa = QualityPointCalculator(final_gpa,final_total)
print('Your overall GPA: %.2f' %(gpa))
Trending nowThis is a popular solution!
Step by stepSolved in 3 steps with 1 images
- Write a program to fill the entire screen with a smiling face. The smiling face has an ASCII value 1.arrow_forwardClear Explanation on this question add some step to leading on how you answerd it neat handwriting and clear explanation table completed Question are below here:arrow_forwardAssign interestPointer with the address of the higher interest. If the interests are the same, then assign interestPointer with nullptr. Ex: If the input is 497 261, then the output is: 497 is the higher interest. #include <iostream>using namespace std; int main() { int interest1; int interest2; int* interestPointer; cin >> interest1; cin >> interest2; /* Your code goes here */ if (interestPointer == nullptr) { cout << "The interests are the same." << endl; } else { cout << *interestPointer << " is the higher interest." << endl; } return 0;}arrow_forward
- ✓ Exercises Exercise: Write a method _ and _ that computes the region representing the intersection of two regions. Exercise: Write a method _contains__, which checks whether a n-dimensional point belongs to the region. Remember, a point belongs to the region if it belongs to one of the rectangles in the region. ✓ Membership of a point in a region #@title Membership of a point in a region def region_contains (self, p): ### YOUR SOLUTION HERE Region._contains = region_contains [ ] # Tests 10 points. assert (2, 1) in Region (Rectangle((0, 2), (0, 3)), Rectangle((4, 6), (5,8))) assert (2, 1) not in Region (Rectangle((0, 1), (0, 3)), Rectangle((4, 6), (5, 8))) Exercise: Write a method _le_ for regions such that R <= S if the region R is contained in the region S. You can test this by checking that the difference between R and S is empty.arrow_forward13. Factorial Implementation What is incorrect with the following implementation of factorial: def factorial(n): return n* factorial(n-1) Pick ONE option Nothing is wrong The return value should be n+ factorial(n-1) The return value should be factorial(n-1) * factorial(n-2) ) A base case is missing Clear Selection loxituarrow_forwarduse this code template to help you continue: private boolean included Indicates whether the item should be taken or not public Item(String name, double weight, int value) Initializes the Item’s fields to the values that are passed in; the included Field is initialized to false public Item(Item other) Initializes this item’s fields to the be the same as the other item’s public void setIncluded(boolean included) Setter for the item’s included field (you don’t need setters for the other fields) Given code: public class Item { private final String name; private final double weight; private final int value; public Item(String name, double weight, int value) { this.name = name; this.weight = weight; this.value = value; } static int max(int a, int b) { if(a > b) return a; return b; } // function to print the items which are taken static void printSelection(int W, Item[] items, int…arrow_forward
- Instructor note: Important Coding Guidelines: Use comments, and whitespaces around operators and assignments. Use line breaks and indent your code. Use naming conventions for variables, functions, methods, and more. This makes it easier to understand the code. Write simple code and do not over complicate the logic. Code exhibits simplicity when it’s well organized, logically minimal, and easily readable. A pedometer treats walking 1 step as walking 2.5 feet. Define a method named feetToSteps that takes a double as a parameter, representing the number of feet walked, and returns an integer that represents the number of steps walked. Then, write a main program that reads the number of feet walked as an input, calls method feetToSteps() with the input as an argument, and outputs the number of steps. Use floating-point arithmetic to perform the conversion. Ex: If the input is: 150.5 the output is: 60 The program must define and call a method:public static int feetToSteps(double…arrow_forward~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~arrow_forwardComputer Science Part C: Interactive Driver Program Write an interactive driver program that creates a Course object (you can decide the name and roster/waitlist sizes). Then, use a loop to interactively allow the user to add students, drop students, or view the course. Display the result (success/failure) of each add/drop.arrow_forward
- $1:When using the test data approach in detecting a problem, the test data must include all possible valid and invalid conditions.$2:Encryption services applied where confidentiality is a stated requirement is an example of systems development and acquisition controls. A. Both Statements are trueB. Only the first statement is trueC. Only the second statement is trueD. None of the statements are truearrow_forwardshow: Lists the items that the wizard is currently carrying along with the index for each item and the weight of that item. See sample runs below. As shown in the sample this function also prints the total weight of the items along with the max weight limit of 100 lbs. Hint: You can use the sum function in Python to calculate the sum of weights. E.g. sum(weights) will return the sum of all the items in the weights list. grab_item: Add a new item while enforcing the following policy: There is a limit of 4 on the number of items the wizard can carry and limit of 100 lbs on the total weight the wizard can carry. So specifically, if the wizard is already carrying 4 items, print message that “You can't carry anymore items. Drop something first.” And return out of the function. Otherwise prompt the user for the name and the weight of the new item. Next check whether with the addition of the new item, the total weight will exceed the limit of 100 lbs. If so, print a message saying weight…arrow_forward16 Type the correct answer in the box. Use numerals instead of words. If necessary, use / for the fraction bar. var num2 = 32; var num1 = 12; var rem=num2 % num1; while(rem> 0) { num2 = num1; num1 = rem; rem =num2 9% num1; document.write(num1): The output of the document.write statement at the end of this block is Reset Next m. All rights reserved. 5896arrow_forward
- Database System ConceptsComputer ScienceISBN:9780078022159Author:Abraham Silberschatz Professor, Henry F. Korth, S. SudarshanPublisher:McGraw-Hill EducationStarting Out with Python (4th Edition)Computer ScienceISBN:9780134444321Author:Tony GaddisPublisher:PEARSONDigital Fundamentals (11th Edition)Computer ScienceISBN:9780132737968Author:Thomas L. FloydPublisher:PEARSON
- C How to Program (8th Edition)Computer ScienceISBN:9780133976892Author:Paul J. Deitel, Harvey DeitelPublisher:PEARSONDatabase Systems: Design, Implementation, & Manag...Computer ScienceISBN:9781337627900Author:Carlos Coronel, Steven MorrisPublisher:Cengage LearningProgrammable Logic ControllersComputer ScienceISBN:9780073373843Author:Frank D. PetruzellaPublisher:McGraw-Hill Education