匿名用户
1级
2017-12-02 回答
导入python提供的random这个库。
Python代码例子
1.输入三个变量,然后按小到大输出
[python] view plain copy
x = int(input("please input x:"))
y = int(input("please input y:"))
z = int(input("please input z:"))
if x > y :
x, y = y, x
if x > z :
x, z = z, x
if y > z :
y, z = z, y
print(x,y,z)
2、求101-200的素数
[python] view plain copy
from math import sqrt
def isprime(n):
k = int(sqrt(n))
for i in range(2,k+1):
if n % i == 0:
return 0
return 1
if __name__ == "__main__":
for n in range(101, 201):
if isprime(n) ==1:
print(n, end = " ")
[python] view plain copy
版本二:
[python] view plain copy
n = int(input(&#