import random
x = random.randint(1,4);
y = random.choice(['appale','banana','cherry','durian']);
print(x,y);
=============================================
不管学哪个语言,我总喜欢弄个随机数玩玩。农历十一月初六,Let's Python!!!
l=[ ]
while True:
name=input("请输入一个名字:")
if name!='':
l.append(name)
else:
break
print(l);
========================================================
'''求1到100直接所有整数的和'''
x=range(1,101,1)
sumi=0
for i in x:
sumi+=i
print(sumi)
========================================================
u1='''求阶乘的一般方法'''
print(u1)
def jc(n):
s=1
for i in range(1,n+1):
s*=i
return s
n = input("n! usage:<number>:")
h = jc(int(n))
print(h)
u2='''通过递归实现阶乘'''
print(u2)
def jch(n):
if(n==1):
return 1
else:
return n*jch(n-1)
un=input("input n:")
s=jch(int(un))
print("n! is ",s)