Найти - Пользователи
Полная версия: Unsupported operand type(s) for ** or pow() 'type' and 'int'
Начало » Python для новичков » Unsupported operand type(s) for ** or pow() 'type' and 'int'
1
Develor
Решил написать программу для решения квадратных уравнений. Вроде написано правильно, но выдает такую ошибку: unsupported operand type(s) for ** or pow() ‘type’ and ‘int’
 import math
a=int(input("a="))
b=int(input("b="))
c=int(input("c="))
x=float
D=float
D=b**2-4*a*c                  
Y=a*(x**2)+b*x+c              #На эту строку ругается   
x1=(-b+math.sqrt(D))/2*a
x2=(-b-math.sqrt(D))/2*a                    
if D==0:
  x=-b/2*a
  print("x=", x)
  if D<0:
    print("Корней нет.")
else:
  print("x1=", x1)
  print("x2=", x2)
FishHook
    
x=float
D=float
А вот это что такое по-вашему? Что вы надеетесь иметь в виде значений переменных x и D?
py.user.next
Тут ещё ошибка при вычислении корней уравнения.

Develor
  
x1=(-b+math.sqrt(D))/2*a
x2=(-b-math.sqrt(D))/2*a

  
>>> -5/2*3
-7.5
>>> -5/(2*3)
-0.8333333333333334
>>>
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB