#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import math
def my_def(a,b,c):
coeffic = [a,b,c]
leng = len(coeffic) - 1
for num in coeffic: #限制输入的数据类型
if not isinstance(num,(int,float)):
raise TypeError('bad operand type')
print('''二元一次方程:
---------------''') #将二元一次方程分为三部分显示符号,系数,幂次数
for i in (0,2):
_i = leng -i
if coeffic[i] != 0:
if coeffic[i] > 0:
if i != 0:
print('+',end = '')
if coeffic[i] !=1:
print(str(coeffic[i]),end = '')
if i != 1 and i != 2:
print('x^%s' %(_i),end = '')
print('''=0
---------------''')
der = pow(b,2)-4*a*c
if der > 0:
print('二元一次方程两个实数根:')
solution_1 = (-b-math.sqr