Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

Step: 1

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

Step: 3

blur-text-image

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

Database Management System MCQs Multiple Choice Questions And Answers

Authors: Arshad Iqbal

1st Edition

1073328554, 978-1073328550

More Books

Students also viewed these Databases questions