RELATEED CONSULTING
相关咨询
选择下列产品马上在线沟通
服务时间:8:30-17:00
你可能遇到了下面的问题
关闭右侧工具栏

新闻中心

这里有您想知道的互联网营销解决方案
Python程序:打印从1到100的Pronic数字

创新互联Python教程:

公司主营业务:网站建设、成都做网站、移动网站开发等业务。帮助企业客户真正实现互联网宣传,提高企业的竞争能力。创新互联建站是一支青春激扬、勤奋敬业、活力青春激扬、勤奋敬业、活力澎湃、和谐高效的团队。公司秉承以“开放、自由、严谨、自律”为核心的企业文化,感谢他们对我们的高要求,感谢他们从不同领域给我们带来的挑战,让我们激情的团队有机会用头脑与智慧不断的给客户带来惊喜。创新互联建站推出商都免费做网站回馈大家。

编写一个 Python 程序,使用 while 循环打印 1 到 100 或一定范围内的 Pronic 数字。这个 Python 示例接受最小值和最大值,并显示该范围内的 Pronic 数字。

def checkPronic(Number):
    i = 0
    flag = 0
    while i <= Number:
        if Number == i * (i + 1):
            flag = 1
            break
        i = i + 1
    return flag

minPro = int(input("Enter the Minimum Pronic Number = "))
maxPro = int(input("Enter the Maximum Pronic Number = "))

print("\nThe List of Pronic Numbers from {0} and {1}".format(minPro, maxPro)) 
for i in range(minPro, maxPro):
    if(checkPronic(i) == 1):
        print(i, end = '   ')

Python 程序使用 for 循环打印从 1 到 n 的 Pronic 数字。

def checkPronic(Number):
    flag = 0
    for i in range(Number + 1):
        if Number == i * (i + 1):
            flag = 1
            break
    return flag

minPro = int(input("Enter the Minimum Pronic Number = "))
maxPro = int(input("Enter the Maximum Pronic Number = "))

print("\nThe List of Pronic Numbers from {0} and {1}".format(minPro, maxPro)) 
for i in range(minPro, maxPro):
    if(checkPronic(i) == 1):
        print(i, end = '   ')
Enter the Minimum Pronic Number = 200
Enter the Maximum Pronic Number = 400

The List of Pronic Numbers from 200 and 400
210   240   272   306   342   380 

新闻标题:Python程序:打印从1到100的Pronic数字
网页地址:http://www.jxjierui.cn/article/dhchoch.html