Question: Data Programming: PYTHON Write a program that calls the following functions to produce the output shown below. calcavg(): takes five grades as parameters and returns

Data Programming: PYTHON

Write a program that calls the following functions to produce the output shown below. calcavg(): takes five grades as parameters and returns the average. getletter(): take the average as a parameter and return the letter grade. You can use the following table to find the letter grades. printresults(): takes the average and letter grade as parameters, and prints the output as shown below. The program before calling the functions should verify the grades and make sure all the grades are numeric. If there are non-numeric grades, it should display the proper message to the user.

Numeric Grade Letter Grade
>=90 A
>=80 B
>=70 C
>=60 D
<60 F

Input:

a) 56 70 80 99 66

b) 83 90 78 98 97

c) 56 70 test 99 66

Output:

a) Average: 74.2 Letter grade: C

b) Average: 89.2 Letter grade: B

c) Error, all grades must be numeric.

Write a program to calculate the bmi(use the same website as assign1-3) and create two functions that are described below. The program calls the functions in order to calculate the bmi and get the bmi category, and then display the output as shown below. The program should only take numeric inputs. calcbmi(): takes the height and weight as parameters and returns the bmi(round it). getcategory(): takes the bmi as a parameter and returns the bmi category.

Input:

a) 65 120

b) 65 cat

Output:

a) BMI: 19.97, and the category is normal.

b) This program only takes numeric input. Program terminated.

Modify the assign1-4 script by adding a function calcinterest(). The function should take the principal, rate, number of payments, and number of years as parameters and returns the interest. The output should be same as the assign1-4.

Input:

a) 100000 4.5 12 30

b) 25000 3.5 12 6

Output:

a) Interest Paid: $284769.8

b) Interest Paid: $5832.5

Write a program that calculates some basic statistics from a set of sales using a function called calstats() that takes the sales as parameters, calculates the min, max, range, and average, and prints the output as shown below. Ensure that all inputs are entered as numbers. In addition, make sure that the correct number of arguments are provided (there should be 5 inputs).

Input:

a) 200 100 50 600 300

b) 100 700 300

c) 100 700 300 test 500

Output:

a) Min: 50 Max: 600 Range: 550 Average: 250

b) The wrong number of sales provided.

c) All inputs should be numeric.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!