簡體   English   中英

用戶在python 3.4中輸入牆信息后,如何使我的繪畫程序繼續進行?

[英]how do I get my paint program to contenue after user inputs wall info in python 3.4

我正在編寫一個繪制程序,該程序應確定繪制矩形地板棚牆的成本。 我假設棚子沒有窗戶,油漆成本是每加侖40美元。 一加侖占地300平方英尺。 我想提示用戶輸入棚子的尺寸。 我還應該使用一個名為paint_cost的函數,該函數將用戶輸入作為參數並返回對棚牆進行油漆的成本。 最后,我必須以貨幣格式表示成本。

我可以說的是,用戶輸入了尺寸,但是在他們輸入尺寸並按下Enter鍵后,它轉到>>> Im,試圖找出我在這里做錯了什么以及如何使其正確運行。

def main():

    wall1 = float(input('enter length of wall 1: '))
    wall2 = float(input('enter length of wall 2: '))
    wall3 = float(input('enter length of wall 3: '))
    wall4 = float(input('enter length of wall 4: '))
    wall_height = float(input('enter height of walls: '))
    combine_walls1 = wall1 + wall2 
    combine_walls2 = wall3 + wall4


def paint_cost(combine_walls1, combine_walls2):
    combined_walls = combine_walls1 + combine_walls2
    Square_foot = combined_walls * wall_height
    gallon = Square_foot / 300
    cost = gallon * 40

    print('total: $', format(paint_cost, ' ,.2f'))



main()
  1. paint_cost不被調用。
  2. paint_cost應該收到wall_height
  3. 打印cost而不是paint_cost中的paint_cost

def main():
    wall1 = float(input('enter length of wall 1: '))
    wall2 = float(input('enter length of wall 2: '))
    wall3 = float(input('enter length of wall 3: '))
    wall4 = float(input('enter length of wall 4: '))
    wall_height = float(input('enter height of walls: '))
    combine_walls1 = wall1 + wall2 
    combine_walls2 = wall3 + wall4
    paint_cost(combine_walls1, combine_walls2, wall_height)  # 1 + 2


def paint_cost(combine_walls1, combine_walls2, wall_height):  # 2
    combined_walls = combine_walls1 + combine_walls2
    Square_foot = combined_walls * wall_height
    gallon = Square_foot / 300
    cost = gallon * 40
    print('total: $', format(cost, ' ,.2f'))  # 3

main()

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM