Question

White a python lottery program: Using random.randit and loop to pick five random numbers from 1...

White a python lottery program:

Using random.randit and loop to pick five random numbers from 1 to 60, and one number from 1-20.

Then print something like: White balls: 10 11 49 60 1 , Red balls: 2

0 0
Add a comment Improve this question Transcribed image text
Answer #1

Python code

# import random package

import random

# print white balls message
print("White balls: ",end="")

# create list of numbers from 1 to 60
white = list(range(1,61))

# iterate loop for 4 times
for i in range(4):
   # get an number randmoly from list white
   v = random.choice(white)

   # print the number randomly generated
   print(v, end=" ")

   # remove the current generated number from list white
   white.remove(v)

# get an number randmoly from list white
v = random.choice(white)

# remove the current generated number from list white
print(v, end=", ")

# create list of numbers from 1 to 20
red = list(range(1,21))

# print red balls message
print("Red balls: ",end="")

# get an number randmoly from list red
v = random.choice(red)

# print the number randomly generated
print(v)

Sample Input/Output

Add a comment
Know the answer?
Add Answer to:
White a python lottery program: Using random.randit and loop to pick five random numbers from 1...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT