Discuss / Python / 保留小数点后两位

保留小数点后两位

Topic source

归帆未至

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

#!/usr/bin/env python3

-- coding: utf-8 --

import math a = float(input('a=')) b = float(input('b=')) c = float(input('c=')) def q(a,b,c): if (b2-4ac)<0: return'此方程无解' else: x1 = float((-b+math.sqrt(b2-4ac))/(2a)) x2 = float((-b-math.sqrt(b**2-4ac))/(2a)) return '%.2f,%.2f' % (x1,x2) print(q(a,b,c))


  • 1

Reply