Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In Python, define two functions called calc _ cirumference and calc _ area, which will calculate the circumference and the area of a circle, respectively,

In Python, define two functions called calc_cirumference and calc_area, which will calculate the circumference and the area of a circle, respectively, based on a radius passed in as an argument. Heres some model code that would calculate a diameter based on a radius argument:
def calc_diameter(radius):
return 2* radius;
And heres how we would call the calc_diameter function from main(), passing a radius of 5:
diam = calc_diameter(5) #variable diam will take on the value of 10
The circumference of a circle is 2 x PI x the radius (2\pi r). The area of a circle is PI x the radius squared (\pi r2). For PI you can either hard-code 3.1415 or plug in math.pi. To square the radius, you can use (radius * radius) or math.pow(radius,2).
Task 2: Define a Main Function
Define a main function using the def keyword. While youre at it, call your main function using the recommended way discussed in this weeks reading and lecture materials (i.e., using an if statement to test the files __name__ variable). Example:
if __name__=="__main__":
main()
Task 3: Calculate the Number of Pizzas
In order to calculate the number of pizzas to make, follow these steps below. You may create any variables you need at any time in your program.
1. Ask the user for 1) the diameter of the pizza and 2) the number of expected guests (see sample output next page).
2. Divide the diameter in half to get the radius, and then get the pizza area by passing the radius to your calc_area function.
3. Calculate the slices per one pizza by dividing the area by 14.125.
4. Calculate the number of slices needed for the party by multiplying the number of guests by 2.
5. Finally, calculate the number of pizzas by dividing the number of slices needed by the number of slices per pizza. Since the caterer does not make fractional pizzas, use the math.ceil function to round up to the next highest integer, to ensure they make enough for the party. Example:
numPizzas = math.ceil(slicesNeeded / slicesPerPizza)
Task 4: Calculate Cups of Cheese Needed for the Crust
To calculate the cups needed to sufficiently stuff the crust:
1. Get the pizzas circumference by passing the radius to your calc_circumference function.
2. Calculate the cups of cheese by dividing the circumference by 80(because there are 8 ounces in a cup, and one ounce of cheese will stuff 10 linear inches of crust) and then multiply that by the number of pizzas. As in task 3, we have to use math.ceil to round up to make sure we have enough. Example:
cupsCheese = math.ceil(pizzaCirc /80)* numPizzas

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_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

Samsung Galaxy S23 Ultra Comprehensive User Manual

Authors: Leo Scott

1st Edition

B0BVPBJK5Q, 979-8377286455

More Books

Students also viewed these Databases questions

Question

6. Have you used solid reasoning in your argument?

Answered: 1 week ago