Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I've started writing this code for a lottery generator. Here is what the question asks for: Can you help me modify my code to make

I've started writing this code for a lottery generator. Here is what the question asks for:

image text in transcribed

Can you help me modify my code to make this work? I feel like I'm on the right path. Appears to be something wrong with my line: lotteryNum.append(random.randint(M))

import random

def lotteryPick(M): if M=5:

lotteryNum=[]

for i in (range (1,M+1),5): lotteryNum.append(random.randint(M)) return lotteryNum print ('The Lucky Numbers are:').format(lotteryPick())

Lottery games award players for money if they are able to match two, three four or five integers from integers selected at random in a range 1 to M (inclusive of M). Simulate a lottery game by designing a well-documented Python function, lotteryPick(M) that accepts an integer greater than five and returns a list of randomly selected integers. You will need to use Python's random module. Also, consider using the sample function embedded in the random module. Your call to sample should be of the form sample(range(1, M+1),5). In addition, your function should NOT return a value when the user selects an M less than 5. Under this condition have your function return an empty list

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

Graph Databases

Authors: Ian Robinson, Jim Webber, Emil Eifrem

1st Edition

1449356265, 978-1449356262

More Books

Students also viewed these Databases questions

Question

Evaluate the benefits and costs of teams

Answered: 1 week ago

Question

=+ (c) From (18.10) deduce T(4) = VIT.

Answered: 1 week ago