price = float(input(\'Enter price: \')) diameter = float(input(\'Enter diameter
ID: 3904034 • Letter: P
Question
price = float(input('Enter price: '))
diameter = float(input('Enter diameter in inches: '))
area = pi*(diameter/2)**2
cost_per_square_inch = price/area
print('Cost per square inch is $%.2f' % cost_per_square_inch)
if cost_per_square_inch > 0.1:
print('The pizza is too expensive')
else:
print('Buy it. It's a good idea!')
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!
* Calculate the total
*Set 3 fields
Example : Enter the price , Enter diameter in inches and Cost per square inches is
*create edit text field in rows of above three fields
* use if statement and other operators
* use grapics.py libaray
and name it pizza.py.....This is a PYTHON language!!!!!!!!!!
Explanation / Answer
from graphics import * def main(): win = GraphWin("Pizza", 700, 300) win.setBackground('black') # Creating our Objects like labels, textfields for entry pt = Point(150, 50) label = Text(pt, "") label.setTextColor('white') label.draw(win) pt2 = Point(150, 90) label1 = Text(pt2, "Enter the Price:") label1.setTextColor('white') label1.draw(win) price = Entry(Point(350, 90), 10) price.setText("0.0") price.draw(win) pt3 = Point(150, 130) label1 = Text(pt3, "Enter the Diameter in inches:") label1.setTextColor('white') label1.draw(win) diameter = Entry(Point(350, 130), 10) diameter.setText("0.0") diameter.draw(win) pt4 = Point(150, 170) label1 = Text(pt4, "Price per square inch is:") label1.setTextColor('white') label1.draw(win) ppsq = Entry(Point(350, 170), 10) ppsq.setText("0.0") ppsq.draw(win) # Performing tasks that are required while True: if price.getText() and diameter.getText(): pr = float(price.getText()) dia = float(diameter.getText()) ar = 3.142 * ((dia/2.0) ** 2) sq = pr / ar ppsq.setText(str(sq)) if sq > .10: label.setText("Pizza is too Expensive") else: label.setText("Buy it. It is a good deal.") win.getMouse() main()
Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.