Hey there, I've never actually used a forum to ask for help on any sort of project before, but I'm a little stuck.. okay, a lot. =D It's probably something really stupid and minuscule, though. Anyway, heres the project.. I hope it's not too confusing:
Write a program that asks the user for the diameter and the cost of a pizza.
Use a function (getInputs()) to get the diameter and cost of the pizza and return the two values.
Use a function (calcArea(diameter)) to calculate the area of the pizza in square inches.
Use a function (calcCostPerSqInch(area, cost)) to calculate the area of a pizza in square inches.
Use a function (printResults(diameter, cost, area, perSq)) to print the results.
Annnnd, here's what I have so far...:
import math def main(): intro() diameter, cost = getInputs() calcArea(diameter) calcCostPerSqInch(area, cost) printResults(diameter, cost, area, perSq) def getInputs(): #prompt for the diameter and cost from the user diameter = input("Enter the diameter (in inches): ") print print cost = input("Enter the cost (in dollars): ") print print return diameter, cost #create calcArea function def calcArea(diameter): area = math.pi * (diameter / 2) ** 2 #create calcCostPerSqInch function def calcCostPerSqInch(area, cost): perSq = area / cost #create printResults function def printResults(): print "For a diameter of ", diameter," inches" print "and a cost of $", cost,":" print "Area in square inches: ", area print "Cost per square inch: $", perSq def intro(): #print explination to the user print "Program to calculate the area and cost" print "per square inch of a pizza." print "You will be asked to enter the diameter" print "of the pizza in inches and the cost in dollars." print main()
Thanks in advance!!