Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Python Lists, Tuples and Functions Tasks to do: (a) Write a function with the name get_grade that takes in thetotal marks as input and calculates

Python Lists, Tuples and Functions

Tasks to do:

(a) Write a function with the name get_grade that takes in thetotal marks as input and calculates the grade according to thefollowing table:

Grade Given when marks are at least 90 86 A+ A A- B+ B B- C+ C C- D+ D  F 82 78 74 70 66 50 Point Equivalent

Note that according to the rules, the total points scored by thestudent are rounded to the nearest integer before assigning them agrade.

(b) The second function you need to write is calculate_sgpa.This function takes in three inputs – each input representing agrade received in a subject – and calculate the Semester GPA (SGPA)based on the point equivalent of the grades. For instance, if thefunction is called with the grades ’A’, ’A’ and ’D’, it will returnSGPA of 3.0 since (4+4+1)/3 = 3.0.

However, this function also allows the caller to calculate SGPAof less than three subjects. The way to do this is to send thevalue ’nothing’ as one or two of the arguments. For example, if thefunction is called with the values ’A’, ’B’, ’nothing’, it shouldreturn 3.5.

Algorithm 1 SGPA Calculation 1: Procedure 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:

The exact method for calculation of SGPA is given in theAlgorithm 1. In this algorithm, the symbol ? isthe assignment operator and ‘increment’ means to increase thevalue of a variable by one.

(c)

Write third function with the name find_cumulative_marks. Thisfunction will be given a list of tuples. For example:

results = [
(’2200001234’, ’Abdullah AlGhamdi’, 64, 78.5, 89, 25, 99), (’2200001235’, ’Hassan AlOtaibi’, 14, 28.5, 83, 76),
(’ 2200001236’, ’Khalid AlShahrani’, 87, None, 1.6)
]

Each tuple represents the scores of a student. The first elementis the university ID of the student and the second is the fullname. The rest of the elements are the student’s score inassignments.

Some students may have submitted more assignments than theothers. For instance, in the example above, the first student hassubmitted 5 assignments while the third has submitted only 3 (ofwhich, the second got a None – meaning it was invalidated). A Nonein the score is the same as a 0.

Your mission, should you choose to accept it, is to writefind_cumulative_marks in a way that it returns the cumulative marksof each student. So, for the case above, it should return a list oftuples as follows:

[
(’2200001234’, ’kristen mark’, 355.5), (’2200001235’, ’Davidsmith’, 201.5), (’2200001236’, ’maria Olsen’, 88.6)
]

Your function should be able to handle any number of tuplesi.e., student records passed to it. If a None is passed to thefunction, it should return a None back. If an empty list is passed,it should, obviously return an empty list back. Make sure youpreserve the order of the tuples within the outer list.

Grade Given when marks are at least 90 86 A+ A A- B+ B B- C+ C C- D+ D F 82 78 74 70 66 62 58 54 RAHMAN IN FAISA 2.00 INIY 1.67 50 Point Equivalent 0 4.00 4.00 3.67 3.33 3.00 2.67 2.33 1.33 1.00 0.00

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Based on the instructions and the provided grade table and SGPA algorithm lets write the three reque... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Matlab An Introduction with Applications

Authors: Amos Gilat

5th edition

1118629868, 978-1118801802, 1118801806, 978-1118629864

More Books

Students also viewed these Programming questions

Question

Income Statement/rax Return Income Expenses...

Answered: 1 week ago