简体   繁体   中英

I am getting an EOF error and don't know how to fix it

I am trying to write a program that fits these rules:
Your lease is up and it's time to move. Unfortunately, you have a lot of stuff and you don't want to spend too much time moving it because you'd rather be practicing your programming skills. Thankfully, you have friends who can help, though this help comes at a cost. Your friends can move 20 boxes an hour, but they require one 16 inch (diameter) pizza for this work. Write a function in Python that takes the number of boxes you have and returns how much square feet of pizza you will have to buy. Use the function header: sqFtPizza(numBoxes)

and have it return the square feet of pizza as a float.

this is the code i have

def sqFtPizza(numBoxes):
    a = 3.14159*(8*8)
    c = 1/12**2
    sqft = a * c
    za =numBoxes/20
    area = za * sqft
    print (area)
def question():
    numBoxes= float(int(input("How many boxes do you have?: " )))
    sqFtPizza(numBoxes)
question() 

please help?

Making the function name PEP8-compliant,

# --- Python 2.x ---
from __future__ import division          # make int/int return float
from math import pi

PIZZA_PER_BOX = pi * (8 / 12)**2 / 20    # one 16" pizza per 20 boxes

def sq_ft_pizza(num_boxes):
    """
    Input:  number of boxes to be moved
    Output: square feet of pizza to feed movers
    """
    return PIZZA_PER_BOX * num_boxes

def main():
    num_boxes = float(raw_input("How many boxes must you move? "))
    print("You need {:0.2f} square feet of pizza!".format(sq_ft_pizza(num_boxes)))

if __name__ == "__main__":
    main()

which runs like

How many boxes must you move? 120
You need 8.38 square feet of pizza!

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM