Question

Python: As you drive across one of the Washington DC monuments, there appeared to be a...

Python: As you drive across one of the Washington DC monuments, there appeared to be a billboard with bold words informing the citizens of DC that the Powerball jackpot has risen to one of the all-time high. As you rest in your deep thoughts thinking that you have chance to win this jackpot. As an IT professional living and working in the District of Columbia area living with five other fellow roommates, who are in the same situation. As the only IT expert in this house, you decided to try your luck and to generate some pseudo-numbers to see this jackpot can be claimed by you and your fellow roommates. Requirements:

• Create one function called “lotto()” with no data inside the parameter area.

• Inside this lotto() function o Write one loop to create the five normal Numbers + Powerball o Write a second loop to create a total of 10 Lottery tickets

• No need to prompt any User for input.

• You can make it fancy to include a main() to call the lotto()

• Must use a python List. Random seed must be feed a time element.
• Must use a python random class aka “import random” and “import time”
• Must use a python random seed function
• Regular numbers are inclusive 1 to 70, Powerball numbers are 1-25 inclusive.

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

Here is the python code with screenshot and comments for each important line

-=====================================================================================-

# import all modules
import random
from datetime import  datetime

def lotto():
# seed the random number with the current time
    random.seed(datetime.now())
    # this will store the lottery numbers for the 10 tickets
    ticket_lottery_number=[]
    for ticket in range(10):
        # this will be a list of five normal number and powerball number
        lottery_number=[]
        for _ in range(5):
            # add the five normal numbers in the list
            lottery_number.append(random.randint(1,70))
        # add the powerball number at the end
        lottery_number.append(random.randint(1,25))

        # add the whole list to the ticket list
        ticket_lottery_number.append(lottery_number)

    # print each ticket
    for ticket in ticket_lottery_number:
        print(ticket)

    # return the list to main() function
    return ticket_lottery_number


def main():
    lotto()

main()

-=====================================================================================-

Add a comment
Know the answer?
Add Answer to:
Python: As you drive across one of the Washington DC monuments, there appeared to be a...
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
  • The following are short Python calculations. Give the answer and the Python code for each. 1....

    The following are short Python calculations. Give the answer and the Python code for each. 1. What is the sum of the numbers from 22:100 incrementing by 2? Do this in two ways: Use a while statement and a for loop to do the calculation. (Hint: make sure the numbers include 100) 2. What is the mean, standard deviation of the square root of the numbers from 3 to 5 incrementing by 0.1? Use the linspace function from the numpy...

  • Assignment: USING PYTHON Expected submission: TWO (2) Python files, main.py and HelperClasses.py Make a file called...

    Assignment: USING PYTHON Expected submission: TWO (2) Python files, main.py and HelperClasses.py Make a file called HelperClasses and create a class inside it called Helpers Inside Helpers, create 8 static methods as follows: 1.) Max, Min, Standard_Deviation, Mean a.) Each of these should take a list as a parameter and return the calculated value 2.) Bubble a.) This should take a list as a parameter and return the sorted list 3.) Median a.) This should take a list as a...

  • CPT 180 Chapter 2 Assignment 3 Directions Using the following guidelines, create a python program. 1....

    CPT 180 Chapter 2 Assignment 3 Directions Using the following guidelines, create a python program. 1. Create a program named printRandomNumbers that gets input from the user and then produces a list of random numbers. 2. Import the random module 3. Add three comment lines at the top of the program that contain: a. Program Name b. Program Description c. Programmer's Name (You) 4. Prompt the user for the following: a. Number of random numbers required b. Lower limit of...

  • I need help writing a very basic code in python. The code should not be very...

    I need help writing a very basic code in python. The code should not be very complicated. The code must have the following things in it: 1. create a function that takes a state and length of characters and makes a license plate and use the function to make a plate based on user input (use the def function and random.choice as well as import random) 2. the license plate should be a mix of random letters and numbers based...

  • Exercise 2 Write a program that simulates the Texas Powerball lottery. You will have to do resear...

    I HAVE A PROBLE WITH THIS JAVA PROBLEM CAN ANYONE HELP ME PLEASE. Exercise 2 Write a program that simulates the Texas Powerball lottery. You will have to do research to find out how many numbers are drawn, and what the range(s) of the numbers are. For this exercise you need to create a class called "Powerbali", which exposes a public function called play'. This function accepts several parameters , which represent the individual numbers the player wants to play....

  • 1.  When using a function in the Python standard library, do you need to import the library...

    1.  When using a function in the Python standard library, do you need to import the library into your program before using the function? 2.  How does the walk of a pseudorandom sequence differ from the walk of a truly random sequence? 3.  Is the computer capable of producing a truly random walk in a reasonable amount of time? 4.  Based on your research in the standard library documentation, what is the name of the function that can be used to generate random integer...

  • Create a Dice Game: PYTHON This game is between two people. They will roll a pair...

    Create a Dice Game: PYTHON This game is between two people. They will roll a pair of dice each 10 times. Each roll will be added to a total, and after 10 rolls the player with the highest total will be the Winner! You will use the RANDOM class RANDRANGE to create a random number from 1 to 6. You'll need a function for "rollDice" to roll a pair of dice and return a total of the dice. You must...

  • java/javafx assignment: Island Paradise just started running their city lotto. You've been tasked with writing a...

    java/javafx assignment: Island Paradise just started running their city lotto. You've been tasked with writing a program for them. The program is going to allow to user to first select their lotto numbers. The program will then randomly generate the winning lotto numbers for the week and then check the winning numbers against the random ticket the user played in the Lotto to see how many numbers the user guessed correctly. The rules for lotto work as follows: Select 7...

  • Write a PYTHON program that will approximate the value of π. You can do this by...

    Write a PYTHON program that will approximate the value of π. You can do this by computing π to be the ratio of the area of a circle to the area of the square that bounds that circle. Assume a circle of radius 0.5 enclosed by a 1x1 square. The area of the circle then is πr^2=π/4, since r=0.5=1/2 and the area of the square is 1. To approximate the ratio, take a large number of uniformly distributed random points....

  • Part 1: Using Idle Write a Python Script that Does the Following 1. At the top...

    Part 1: Using Idle Write a Python Script that Does the Following 1. At the top of your program, import the math library as in from math import * to make the functions in the math module available. Create a variable and assign into it a constant positive integer number of your choice. The number should be at most 10. 1 Suppose we call this variable x for this writeup document Try something like x = 4 2. Create another...

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
ADVERTISEMENT