0
私はこれを正しく実行することはできません、私は3つの関数を使用する必要があります。 ap()
機能でl
とw
を渡すとmain()
機能でそれらにアクセス:私は正しく私のプログラムで関数を呼び出す/返すとは思わない
def lw():
l = input("Enter the length of your rectangle: ")
w = input("Now enter the width of your rectangle:")
return l, w
def ap():
l,w = lw()
area = l * w
perimeter = 2*1 + 2*w
return area, perimeter
def main():
area,perimeter = ap()
print("With a length of", l ."and a width of", w)
print("the area of your rectangle is", area)
print("the perimeter of your rectangle is", perimeter)
if __name__ == "__main__":
main()
'l'と' w'は文字列であり、intやfloatなどではありません。 'int()'や 'float'呼び出しで' input(..) '呼び出しをラップする必要があります。 –
また、 'l'および' w'は 'lw'関数と' ap'関数のローカル変数です。コードが現在書かれているので、 'main'はそれらにアクセスできません。最後に、境界計算にはタイプミスがあると思います。 – cco