Ошибка NameError:

LonelyWorld

Новичок
Пользователь
Ноя 8, 2020
5
0
1
Python:
figure = str(input())
if figure == "треугольник":
    a = int(input())
    b = int(input())
    c = int(input())
p = (a + b + c ) // 2
S = (p*(p-a)*(p-b)*(p-c))**0.5
print(S)
if figure == "прямоугольник":
    a = int(input())
    b = int(input())
print(a * b)
if figure == "круг":
    r = int(input())
print(3.14 * (r**2))

Traceback (most recent call last):
  File "jailed_code", line 7, in <module>
    p = (a + b + c ) // 2
NameError: name 'a' is not defined
 

regnor

Модератор
Команда форума
Модератор
Июл 7, 2020
2 625
469
83
Python:
figure = input()
if figure == "треугольник":
    a = int(input())
    b = int(input())
    c = int(input())
    p = (a + b + c ) // 2
    S = (p*(p-a)*(p-b)*(p-c))**0.5
    print(S)
elif figure == "прямоугольник":
    a = int(input())
    b = int(input())
    print(a * b)
elif figure == "круг":
    r = int(input())
    print(3.14 * (r**2))
 

Форум IT Специалистов