Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

PYTHON You must define the functions indicated in question (1) and use those functions appropriately in the main program. Do not use any global variables

PYTHON

You must define the functions indicated in question (1) and use those functions appropriately in the main program. Do not use any global variables in the functions. Not following those specifications will result in earning 0 points for the specification item of the rubric.

(1) Write the definition of functions with the following specification:

discArea(diameter): Returns the area of a disc with the given diameter

costPerSquareInch(diameter, price): Returns the cost per square inch of a pizza given the diameter of the pizza and its price. The cost per square is returned in cents and the price of the pizza is in dollars.

Note that the functions will be tested separately.

(2) Write a program that prompts for the diameter and price of one pizza and output the cost per square inch in cents rounded to two decimal places. Code for this program must be entered after the statement: if __name__ == "__main__":

If the input is

14 14.5 

the output begins with

Enter diameter of pizza: Enter price of pizza: Cost per square inch is 9.42 cents. 

(3) Extend the program to prompt for the diameter and price of a second pizza.

If the input is

14 14.5 12 12.5 

the output begins with

 Enter diameter of pizza: Enter price of pizza: Cost per square inch is 9.42 cents. Enter diameter of second pizza: Enter price of second pizza: Cost per square inch is 11.05 cents. 

(4) Extend the program so that it prints which of the two pizzas is a better deal.

Important: The cost per square inch must be rounded to two decimals.

If the input is

14 14.5 12 12.5 

the output ends with

 The 14-inch pizza is a better deal. 

If the input is

14 14.5 12 12.5 

the output ends with

 Prices of the two pizzas are equivalent. 

----------------------------------------------------------------------------------------------------------------------------

import math

# define discArea

# Define costPerSquareInch

# Main program if __name__ == "__main__":

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

Students also viewed these Databases questions

Question

4. What should learners revisit and remember?

Answered: 1 week ago

Question

Provide examples of KPIs in Human Capital Management.

Answered: 1 week ago

Question

What are OLAP Cubes?

Answered: 1 week ago