Discuss / Python / 作业

作业

Topic source

wjswjx

#1 Created at ... [Delete] [Delete and Lock User]

#!/usr/bin/env python

-- coding: utf-8 --

import math a = int(input('Please enter a:')) if a == 0 : print('不是一元二次方程,a不能为零') exit() b = int(input('Please enter b:')) c = int(input('Please enter c:')) deta = bb-4ac def quadratic(a,b,c): if deta <=0: return '无解' else: x1 = (-b+math.sqrt(deta))/(2a) x2 = (-b-math.sqrt(deta))/(2*a) return x1,x2 print('两个解分别为:',str(quadratic(a,b,c)))


  • 1

Reply