小编Luk*_*man的帖子

Python程序输出不同的结果,即使没有使用随机

我正在努力解决Project Euler Problem 19.

我不是在这里要求问题的答案,但我注意到每次我的程序运行时,它的输出都是不同的.

请有人为我解释原因

"""
    Author: Luke Spademan
    Calculates answer to project euler problem id19
    https://projecteuler.net/problem=19
"""


def calculate():
    ans = 0
    months = {
        "jan": 31,
        "feb": 28,
        "mar": 31,
        "apr": 30,
        "may": 31,
        "jun": 30,
        "jul": 31,
        "aug": 31,
        "sep": 30,
        "oct": 31,
        "nov": 30,
        "dec": 31,
    }
    i = 1
    for year in range(1901, 2001):
        for month in months:
            months["feb"] = 28
            if year % 4 == 0 and not (year % 100 …
Run Code Online (Sandbox Code Playgroud)

python python-3.x

6
推荐指数
1
解决办法
79
查看次数

标签 统计

python ×1

python-3.x ×1