Python Code : LOTTO Machine
LOTTO MACHINE PYTHON CODE
A complete Python Code that generates lotto numbers and matches them with the user's. Note, I was too lazy to do the generator to not repeat the numbers generated into the list. Basically anyone can alter that to making it do the right thing. Just follow the exact steps that I used to make the user not to repeat the numbers, it should work the same way. This code is 100% working and it it completely mine and I give it to newbies in python to use it as practice (do not cheat, learn to code) this is just to show you how its done.
Find me on facebook : http://www.facebook.com/leander101
Or you can simply comment and subscribe.
That's what she said...
_________________________________________________________________________________
#-----------------------------------------------------------
# Name : CompleteLottoMachine.py
# Purpose : Play Lotto
#
# Author Mafanga Lolito (3138295)
#
# Created 07-March-2013 to 08-March-2013
# Copyright (c) 2013 by Samdpix
# Licence wxWindows licence
#------------------------------------------------------------
from random import randint
randListing =[]
count1 =0
while count1 !=6:
randList = randint(1,45)
randListing.append(randList)
count1 +=1
if count1 == 6:
break
players = []
yourWinnings=[]
length = len(players)
count =0
number =0
# This is for the Runner (Not The Player), To Know the Random Numbers, otherwise I could delete this
print "------------<<< IF YOU WANT TO CHEAT !! >>>---------"
print "\tThese Are Randomly Generated Numbers:"
print "\t\t (LOTTO NUMBERS!!)"
print "\t ",randListing
print "-----------------------------------------------------"
#____________________________________________________________________________________________________
while True:
while True:
try:
number = int(input("Enter number "+str(count+1)+" : ->" ))
if number in players:
print "-------------------"
print "There is already",number
print "-------------------"
number = Non
elif number > 45:
print "\nEnter Numbers Less than 45"
print "---------------------------------"
number = Nom
elif number <=0:
print "\nEnter Numbers Greater than Zero"
print "-----------------------------------"
number = Non
break
except:
print "\nInvalid Entry!!"
print "---------------"
players.append(number)
count +=1
if count == 6:
print "\n----------------------<< DONE !!>>-----------------------------"
break
for i in randListing:
if i in players:
yourWinnings.append(i)
print "\n---------------------<< RESULTS!! >>---------------------------"
print "You got ",len(yourWinnings),"Winning Numbers!"
print "----------------------------------------------------------"
print "These are the Numbers You Entered :- >",players
print "These are the Winning Lotto Numbers :- >",randListing
print "These are Your Winning Numbers :- >",yourWinnings
# If you Are running it in the Python Command Prompt (CMD)
# It allows you to see the Results before exiting on its own.
raw_input("< ENTER TO EXIT !! >>")
Comments
Post a Comment
Be real!