Py学习  »  Python

python函数不返回任何内容

J.Xu • 7 年前 • 2058 次点击  

我正在做我的作业,结果出现了一些问题,我想在我的函数中返回“真”或“假”,但最后什么也没有显示。

import math
import decimal

#1
def pythagorean_pair():
    a = input("Type a number A(Must be an integer): ")
    if a.isdigit():
        a=int(a)
        b = input("Type a number B(Must be an integer): ")
        if b.isdigit():
            b = int(b)
            c = a**2 + b**2
            ans = c**(1/2)
            ans = ans - int(ans)
            if ans == 0:
                return (True)
                print ("True, they are pythagorean pair!")
            else:
                return (False)
                print ("False, they are not pythagorean pair!")
        else:
            print ("Please input an integer!!")
    else:
        print ("Please input an integer!!")
pythagorean_pair()
Python社区是高质量的Python/Django开发社区
本文地址:http://www.python88.com/topic/39197
文章 [ 3 ]  |  最新文章 7 年前