攝影或3C

Python綜合範例13 樂透號碼 import random, lottoNum = random.randint(1,49)

#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:

 

儲蓄保險王

儲蓄險是板主最喜愛的儲蓄工具,最喜愛的投資理財工具則是ETF,最喜愛的省錢工具則是信用卡