Question

Given the radius, in inches, and price of a pizza, write a program to find the...

  1. Given the radius, in inches, and price of a pizza, write a program to find the price of the pizza per square inch. Use float data type and format to 2 decimal places. You must have a $ sign for the price per square inch. Use math.pi to get the value if PI.  

To do this use:

import math

PI = math.pi

And then use PI to calculate area of pizza. Name your file ws3part1.py. Read the style guidelines before you submit the file.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

# Please refer to the screenshots to understand it better.

# Feel free to ask any doubts or queries by commenting on the answer

import math

# Take value of radius of pizza as input from user and store it in variable 'radius'
radius = float(input('Enter radius of the pizza (in inches): '))

# Take value of price of pizza as input from user and store it in variable 'price'
price = float(input('Enter price of the pizza (in dollars): '))

# Store value of pi into variable 'PI'
PI = math.pi

# Calculate area of the pizza and store it in variable 'area'
area = PI*radius*radius

# Calculate price per square inch of pizza and store it in variable 'ppi'
ppi = price/area

# Format the obtained price per square inch to 2 decimal places
ppi = '%.2f' % ppi

# Print the obtained price per square inch of the pizza
print ('The price of the pizza per square inch is $' + ppi)

Add a comment
Know the answer?
Add Answer to:
Given the radius, in inches, and price of a pizza, write a program to find the...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write a graphics program to calculate the cost per square inch of a circular pizza and...

    Write a graphics program to calculate the cost per square inch of a circular pizza and use graphics .py libaray. Accept as input the diameter (in inches) and pizza price. Print the cost per square inch. If the cost per square inch is more than $.10 print a message that informing the user that this pizza is too expensive. Otherwise let the user know this is a good deal! and name it pizza.py

  • Write a graphics python program!!!!!!! to calculate the cost per square inch of a circular pizza...

    Write a graphics python program!!!!!!! to calculate the cost per square inch of a circular pizza and use graphics .py libaray!!!!! . Accept as input the diameter (in inches) and pizza price. Print the cost per square inch. If the cost per square inch is more than $.10 print a message that informing the user that this pizza is too expensive. Otherwise let the user know this is a good deal! and name it pizza.py.....This is a PYTHON language!!!!!!!!!!

  • (The file should have your program and the console input/output of your program) 3.18: Pizza Pi...

    (The file should have your program and the console input/output of your program) 3.18: Pizza Pi Joe’s Pizza Palace needs a program to calculate the number of slices a pizza of any size can be divided into. The program should perform the following steps: Ask the user for the diameter of the pizza in inches. Calculate the number of slices that may be taken from a pizza of that size. Display a message telling the number of slices. To calculate...

  • Need help with this problem by using JAVA and in second picture I have circled the...

    Need help with this problem by using JAVA and in second picture I have circled the Extra Credit, if possible. Please help and Thank you so much in advance.! 2.1 Area of a Pizza Pie Pizzas in the USA are just big circles of bread, cheese, and tomato sauce, mea- sured by the size of their diameter in inches. You can use that to get the area of the circle, which is measured in square inches. Write a method which...

  • Write a C program named assignment04.cpp that will ask for and read in a float for...

    Write a C program named assignment04.cpp that will ask for and read in a float for a radius ask for and read in a float for the height each of the following functions will calculate some property of a shape (area, volume, circumference, etc) The functions will accept one or two parameters (radius and/or height) and return the proper calculation. There is no input/output (cin or cout) in the function – just the calculation write the following functions float areaCircle(float...

  • Problem: Write a short C++ program that gets the side of a cube and the radius...

    Problem: Write a short C++ program that gets the side of a cube and the radius of a sphere from the keyboard and writes to a file the surfaces of these shapes.             ------------------------------------------------------------------------------------------------------------------------ Your task: implement in C++ the algorithm solution shown below. ------------------------------------------------------------------------------------------------------------------------ Part A (79 points) Algorithm solution (in pseudocode): To accomplish this task, your program will have to take the following steps: 1. Declare a variable named outFile that represents an output stream. 2. Declare a...

  • Write a class named HalfOpenCylinder that has two data members: a double for the height in inches and a double for the radius in inches. It should have a constructor that takes two parameters and uses...

    Write a class named HalfOpenCylinder that has two data members: a double for the height in inches and a double for the radius in inches. It should have a constructor that takes two parameters and uses them to initialize the data members. It should have a default constructor that initializes the height to 10 and the radius to 2. It should have a method named surfaceArea that returns the the surface area (in square inches) of a cylinder with that...

  • C++ Pr ogramming (CSC-115) Functions (pass by Reference) Programming project Using FUNCTIONS, write a C++ program...

    C++ Pr ogramming (CSC-115) Functions (pass by Reference) Programming project Using FUNCTIONS, write a C++ program that calculates the Area of a cirele, a square and a rectangle. Your program must prompt the user to select which area is to be calculated. Document your program. Apply the do while loop to repeat the program Apply the while loop for input validation. Apply the switch statements or the if/ else if statement to prompt the user for the area's selection. Based...

  • A) One of the problems that have been discussed in the class is to write a simple C++ program to ...

    C++ programming question will upvote A) One of the problems that have been discussed in the class is to write a simple C++ program to determine the area and circumference of a circle of a given radius. In this lab you will be rewriting the program again but this time you will be writing some functions to take care of the user input and math. Specifically, your main function should look like the following int main //the radius of the...

  • I've written this program in C++ to compare 2 pizzas using classes and it works fine....

    I've written this program in C++ to compare 2 pizzas using classes and it works fine. I need to convert it to java using both buffered reader and scanner and can't get either to work. //C++ driver class for Pizza program #include <iostream> #include <string> #include <algorithm> #include <iomanip> using std::cout; using std::cin; using std::string; using std::endl; using std::transform; using std::setprecision; using std::ios; using std::setiosflags; #include "Pizza.h" int main() {             char response = 'Y';             while (response == 'Y')...

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT