首页 > 解决方案 > 如何在 Python 中创建构建文件或 sh 文件

问题描述

# Python3 code to check if a given
# number is perfect or not
 
# Returns true if n is perfect
def isPerfect( n ):
     
    # To store sum of divisors
    sum = 1
     
    # Find all divisors and add them
    i = 2
    while i * i <= n:
        if n % i == 0:
            sum = sum + i + n/i
        i += 1
     
    # If sum of divisors is equal to
    # n, then n is a perfect number
     
    return (True if sum == n and n!=1 else False)
 
# Driver program
print("Below are all perfect numbers till 10000")
n = 2
for n in range (10000):
    if isPerfect (n):
        print(n , " is a perfect number")
         
# This code is contributed by "Sharad_Bhardwaj".

嗨,我想知道如何创建构建文件或 sh 文件,以便在将代码发送给其他人时编译和运行代码。这只是一个示例,如果我有这样的代码,我如何创建构建文件或 sh 文件以便自动编译和运行代码?

标签: pythonbuild

解决方案


推荐阅读