我是靠谱客的博主 追寻纸飞机,这篇文章主要介绍python multiple assignment demo,现在分享给大家,希望可以做个参考。

#quote from 'introduction to computation and programming using python, revised edition, MIT'
def findExtremeDivisors(n1, n2):
    """Assumes that n1 and n2 are positive ints
       Returns a tuple containing the smallest common
       divisor > 1 and the lergest common divisors of n1 
       and n2"""
    minVal, maxVal = None, None
    for i in range(2, min(n1, n2) + 1):
        if n1%i == 0 and n2%i == 0:
            if minVal == None or i < minVal:
                minVal = i
            if maxVal == None or i > maxVal:
                maxVal = i
    return (minVal, maxVal)

最后

以上就是追寻纸飞机最近收集整理的关于python multiple assignment demo的全部内容,更多相关python内容请搜索靠谱客的其他文章。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(107)

评论列表共有 0 条评论

立即
投稿
返回
顶部