Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a code using Python: Lottery Number Generator) that we will build on to make a game. As the book describes, generate random numbers in

Write a code using Python:

Lottery Number Generator) that we will build on to make a game. As the book describes, generate random numbers in the range 0 through 9 and store them in a List

Start the player with 100 chips. Ask them how many they want to bet (must be in the range 1 through 10). Once you have their bet amount, give them the following choices:

Pick 1 (Put 3 numbers in List (0 through 9, duplicates are ok), they pick one number, if they match one of the numbers they win the amount of their bet, along with getting their bet back)

Pick 2 (Put 3 numbers in a List, they pick 2 numbers, if they match both they win twice the amount of their bet, along with getting their bet back)

Jumbo (Put 7 numbers in a List, they pick 7 numbers, they win a lot (you choose amount) if they match all 7, they win almost that amount if they match 6, a bit less if they match 5, a bit less if they match 4, and finally they win something if they match 3 (matching less than 3 is a loss))

here is what i have so far:
import random
def main():
PICK_1 = 3
PICK_2 = 3
JUMBO = 7
PLAYER_PICK_1 = 1
PLAYER_PICK_2 = 2
PLARYER_JUMBO = 7
lottoNum = []
playerNumbers = []
counter = 0
lottoNum = genLottoNum( PICK_1 )
playerNumbers = playerNum( lottoNum )
print("Your picks are: " )
printPlayerNum( playerNumbers )
print("The", PICK_1, "lottery numbers for today are: " )
printLottoNum( lottoNum )
print("You have guess " + str(counter) + " number(s) correctly." )
def genRanNum():
randNum = random.randint( 0, 9 )
return randNum
def genLottoNum( numberOfLottoNum ):
lottoNum = []
for currentLottoNumIndex in range( numberOfLottoNum ):
randNum = genRanNum()
randNum = random.randint( 0, 9 )
lottoNum.append( randNum )
return lottoNum
def printLottoNum( lottoNum ):
for currentLottoNumIndex in range( len( lottoNum ) ):
print( lottoNum[ currentLottoNumIndex ] )
def playerNum( lottoNum ):
playerNumbers = []
for currentPlayerNumIndex in range( len( lottoNum )):
number = int(input("Please enter a number between 0 and 9: " ) )
while ( number<0 or number>9):
print("Invalid number! Please try again." )
number = int(input("Please enter a number between 0 and 9: " ) )
playerNumbers.append(number)
counter = 0
for number in playerNumbers:
if number in lottoNum:
counter += 1
print("You have guess " + str(counter) + "number(s) correctly." )
return playerNumbers, counter
def printPlayerNum( playerNumbers ):
for currentPlayerNumIndex in range( len( playerNumbers ) ):
print( playerNumbers[ currentPlayerNumIndex ] )
main()

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

T Sql Window Functions For Data Analysis And Beyond

Authors: Itzik Ben Gan

2nd Edition

0135861446, 978-0135861448

More Books

Students also viewed these Databases questions