我对编码比较陌生,所以请在这里帮助我。代码只会运行到第 5 行。这段代码可能是一个通通的,但请幽默我。
编辑:没有例外,没有任何反应。在要求我在 1 和 2 之间进行选择后,代码就停止了。
print('This program will tell you the area some shapes')
print('You can choose between...')
print('1. rectangle')
print('or')
print('2. triangle')
def shape():
shape = int(input('What shape do you choose?'))
if shape == 1: rectangle
elif shape == 2: triangle
else: print('ERROR: select either rectangle or triangle')
def rectangle():
l = int(input('What is the length?'))
w = int(input('What is the width?'))
areaR=l*w
print('The are is...')
print(areaR)
def triangle():
b = int(input('What is the base?'))
h = int(input('What is the height?'))
first=b*h
areaT=.5*first
print('The area is...')
print(areaT)