Notice
Recent Posts
관리 메뉴

Hacking Arts

[python] lotto game 본문

Programing/Program

[python] lotto game

Rakehell 2015. 10. 31. 18:41
#!/usr/bin/python
import random
import time

####### money value ######
money=random.randrange(1000000,30000000)*1000

###### lotto value ######
rand=set()
	
while len(rand) < 4 :
	rand.add(random.randrange(1,18))

lotto=list(rand)
lotto.sort()
print (lotto)
##### input #####

select=[]
i=1
while i < 5 :
	num=input("your "+str(i)+" input(space) : ")
	if num > 0 and num < 19 :
		select.append(num)
		i+=1
	else :
		print "input number(0~18)"

select.sort()

lotto_set=set(lotto)
select_set=set(select)

sets_tmp=lotto_set | select_set

sets=list(sets_tmp)
match=int(len(sets))

if match==4:
	winnings=int(money*0.4)
elif match==5:
	winnings=int(money*0.1)
elif match==6:
        winnings=int(money*0.01)
elif match==7:
        winnings=5000
else :
	winnings=0

#time.sleep(1)
print(match)
print "Winnings : %d" %winnings

'Programing > Program' 카테고리의 다른 글

[python] Baseball game  (0) 2015.01.26