Discuss / Python / 把运行结果贴出来

把运行结果贴出来

Topic source

Android阳

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

用IDLE新建保存文件。新建函数,然后F5运行的

# -*- coding: utf-8 -*-

import math

def quadratic(a, b, c):
    dlt = b**2-(4*a*c)
    dltrt = math.sqrt(dlt)
    if 0 > dlt :
        return '此方程实数无解!'
    elif 0 == dlt :
        return '实数两个相等的根:' + str(-(b/2*a))
    elif 0 < dlt :
        return (-b+dltrt)/(2*a), (-b-dltrt)/(2*a)

下面是运行结果

Python 3.5.1 (v3.5.1:37a07cee5969, Dec  6 2015, 01:54:25) [MSC v.1900 64 bit (AMD64)] on win32
Type "copyright", "credits" or "license()" for more information.
>>> 
=============== RESTART: C:\Users\Administrator\Desktop\jjj.py ===============
>>> print(quadratic(2, 3, 1))
(-0.5, -1.0)
>>> print(quadratic(1, 3, -4))
(1.0, -4.0)
>>>

  • 1

Reply