python - 如何在 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 文件以便自动编译和运行代码?
解决方案
推荐阅读
- scala - 将 DistributedCache 文件保存在每个节点的磁盘上而不做任何工作
- c++ - 在不破坏现有基类的情况下向具有许多派生类的抽象基类添加新方法
- java - Jackson Json Wrap 现场级别
- html - 为什么 Alegreya 字体在某些浏览器中无法正确显示?
- node.js - 带有客户端加密值的 Mongoose Model.find()
- sqlalchemy - Flask-SQLAlchemy 通过 IAM 连接到 RDS-proxy
- azure - 如何为 Get-AzSubscription 传递特定值
- r - 在 Mambaforge 的 Snakemake 工作流程中使用 R
- angular - 在返回值之前等待 observable 在每个数组中完成
- python - Prolog 嵌套查询