#Python 3.X 程式語言特訓教材 6-42頁
import random
def lotto():
lottoLst=[]
cnt=0
while cnt <6 :
lottoNum = random.randint(1,49)
if lottoNum not in lottoLst:
lottoLst.append(lottoNum)
cnt += 1
lottoLst.sort()
print(lottoLst)
def main():
for i in range(1,6): #i=1,2,3,4,5
lotto()
main()
#綜合範例14
import random
randLst=[]
for i in range(100):
randNum = random.randint(1,1000)
randLst.append(randNum)
#print(randLst)
randLst.sort()
for j in range(1,101):
if j%10 == 0: print(“%4d” %randLst[j-1])
else:print(“%4d” %randLst[j-1],end=””)
print()
print(randLst[1])
print(randLst[-2])
#6-47: