[SOLVED] Help! How much [python]


 Calculate the perimeter and the area of the garden
# and pay the fair price for that.

# The prices for fences and lawns.
fencePrice = 3 # per meter.
lawnPrice = 2 # per square meter.
# You need the foreman.
foreman = hero.findNearest(hero.findFriends())
corners = foreman.corners
# Get the information about the garden.
bottomLeft = corners.bottomLeft
topRight = corners.topRight
# Calculate the size of the garden.
width = topRight.x - bottomLeft.x
height = topRight.y - bottomLeft.y
# Find the perimeter of the garden (meters):
perimeter = (width + height) * 2
# Use fencePrice and calculate the fence cost:
fencePrice = perimeter / fencePrice
# Find the area of the garden (square meters):
area = width * height
# Use lawnPrice and calculate the lawn cost:
lawnPrice = area / lawnPrice
finalPrice = fencePrice + lawnPrice
# The total cost is the sum of the fence and the lawn costs
totalCost = finalPrice # Δ Update this with the final price!
hero.say("The total price is " + totalCost)
# Pay the bill.

None, but it doesn’t succeed.



Check these lines:

lawnPrice = area / lawnPrice

Is that what you’re meaning to do?


1 Like

Ah yes! So clumsy!
Thanks a bunch!

This topic was automatically closed 12 hours after the last reply. New replies are no longer allowed.