使用 Python 实现随机生成 200 无重复**码(或者优惠券),字符串长度大于5以上. import random count = 0 s1 = set() while True: s = 'abcdefghjkl1234567890' ys = '' for i in range(6): ys += random.choice(s) print (ys) s1.add(ys) if len(s1) == 200: break print(s1) 打印出100以内的斐波那契数列,使用2种方法实现.
lst=[1,1]
for i in range(2,20):
print(lst)
if lst[i-1] + lst[i-2] > 100:
break
lst.append(lst[i-1] + lst[i-2])
print(lst)
# 鑾峰彇鐢ㄦ埛杈撳叆鏁版嵁
nterms = int(input("浣犻渶瑕佸嚑椤癸紵"))
# 绗竴鍜岀浜岄」
n1 = 0
n2 = 1
count = 2
# 鍒ゆ柇杈撳叆鐨勫€兼槸鍚﹀悎娉�
if nterms <= 0:
print("璇疯緭鍏ヤ竴涓鏁存暟銆�")
elif nterms == 1:
print("鏂愭尝閭e鏁板垪锛�")
print(n1)
else:
print("鏂愭尝閭e鏁板垪锛�")
print(n1,",",n2,end=" , ")
while count < nterms:
nth = n1 + n2
print(nth,end=" , ")
# 鏇存柊鍊�
n1 = n2
n2 = nth
count += 1
交作业过程:
1、
2、跳转D盘,
在命令行输入 git clone https://github.com/magedus/python-11.git
3、
$git add suqiangqiang/
$git commit -m "jowin's homework directory"
4、
$git push origin master