Question

Devlop a python program as simple as possible:

Make sure the program run properly and Incude the ouput with the program.Thanks.

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

from random import randint

def randlist():

ans = []

for i in range(6):

ans.append(randint(1,59))

#print(ans)

return ans

def comparelist(x, y):

z = list(set(x).union(set(y)))

if len(z) is len(x):

return True

return False

l = input("Enter six numbers for the lottery:")

l = l.split()

try:

for a in range(0,len(l)):

l[a] = int(l[a])

except:

print("Enter integer values")

l.sort()

l = list(set(l))

if(len(l)!=6):

print("Invalid input")

exit()

for a in range(6):

if(l[a]<1 and l[a]>59):

print("Invalid input")

exit()

for i in range(1,9001):

rlist1 = randlist()

rlist1.sort()

if comparelist(l,rlist1):

cost = (i-1)*3+1

print("On week "+i+", numbers are:"+','.join(rlist1))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

rlist2 = randlist()

rlist2.sort()

if comparelist(l,rlist2):

cost = (i-1)*3+2

print("On week "+i+", numbers are:"+','.join(rlist2))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

rlist3 = randlist()

rlist3.sort()

if comparelist(l,rlist3):

cost = (i-1)*3+3

print("On week "+i+", numbers are:"+','.join(rlist3))

print("You are a MILLION DOLLAR winner!!")

print("Your total return is $"+str(1000000-cost))

print("Total amount spent is $"+str(cost))

exit()

cost = 9000*3

print("Total amount spent is $"+str(cost))

Use these images to adjust the indentation.

The sample output is:

apples-MacBook-Pro : python Rajeev$ python3 lottery . py Enter six numbers for the lottery:1 2 3 45 6 Total amount spent is $

Add a comment
Know the answer?
Add Answer to:
Devlop a python program as simple as possible: Make sure the program run properly and Incude...
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
  • Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program...

    Using C++ create a lotto program Lottery Design a program that simulates a lottery. Requirements:  The program should have an array of 5 integers named lottery and should generate a random number in the range of 1 through 99 for each element of the array. The user should enter five digits, which should be stored in an integer array named user. The program is to compare the corresponding elements in the two arrays and keep a count of the digits that...

  • 5.4 Java Create a program that generates SuperLotto lottery numbers. Create a class called SuperLottoPlus.java Create...

    5.4 Java Create a program that generates SuperLotto lottery numbers. Create a class called SuperLottoPlus.java Create a method called generateSuperLottoNumbers() that returns an array of 6 random SuperLotto lottery numbers. The first 5 numbers must be from the range 1 to 47 The 6th number (the MEGA) must be from 1 to 27. Create a method called printTicket() that takes an integer array as an parameter it will loop through the integer array and print out the data Display the...

  • Design a program using Python and using from flask Import flask that generates a lottery number...

    Design a program using Python and using from flask Import flask that generates a lottery number but in a website.. The program should have an Integer array with 9 elements. Write a loop that steps through the array, randomly generating a number in the range of 0 through 42 for each element. (Use the random function) Then write another loop that displays the contents of the array. Each number should be displayed as a list, the numbers should be generated...

  • Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive...

    Lottery Game (15 Numbers). Design and implement a C++ program that generates 15 random non-repeating positive integer numbers from 1 to 999 (lottery numbers) and takes a single input from the user and checks the input against the 15 lottery numbers. The user wins if her/his input matches one of the lottery numbers. Your implementation must have a level of modularity (using functions) Functions you need to implement: Define function initialize() that takes array lotterNumbers[] as a parameter and assigns...

  • JAVA Lab -Lottery Calculator IMPORTANT: This lab is best implemented using a loop structure. If you...

    JAVA Lab -Lottery Calculator IMPORTANT: This lab is best implemented using a loop structure. If you implement this without a loop, you would need to run your program once for each test item. Create a java program that will test for winning numbers on a lottery game. Each lottery ticket will have 5 integer numbers. Valid numbers must be integer numbers between 1 and 55 Assume that the winning Lottery ticket is 1 9 15 33 40 Your program is...

  • i need a help pleassssse? 5. What is the probability that the sum of the numbers...

    i need a help pleassssse? 5. What is the probability that the sum of the numbers on two dice is even when they are rolled? 6. What is the probability that a card selected at random from a standard deck of 52 cards is an ace or a heart? What is the probability that a positive integer not exceed- 100 selected at random is divisible by 5 or 7? nd the probability of winning a lottery by selecting the t...

  • C PROGRAM, A FOPEN FILE NEED TO BE CREATED Objective To review reading from a file....

    C PROGRAM, A FOPEN FILE NEED TO BE CREATED Objective To review reading from a file. To use records (an instance of a struct) To use Dynamic Memory Allocation To create and use a dynamically allocated array of structs To use enumerated types in a useful manner (more info given on Discussion board!) The Problem Bad economic times has forced the UCF administration to think outside the box for alternative methods of income. Specifically, we now have a UCF lottery,...

  • Use C programming Make sure everything works well only upload Write a program that takes an...

    Use C programming Make sure everything works well only upload Write a program that takes an integer from standard input and prints all prime numbers that are smaller than it to standard output. Recall that a prime number is a natural number greater than 1 whose only positive divisors are 1 and itself. At the start of the program, prompt the user to input a number by printing "Input a number greater than 2:\n". If the user's input is less...

  • In python language Write a program that lets the user play the game of Rock, Paper,...

    In python language Write a program that lets the user play the game of Rock, Paper, Scissors against the computer. The program should work as follows: 1. When the program begins, a random number in the range of 1 and 3 is generated. 1 = Computer has chosen Rock 2 = Computer has chosen Paper 3 = Computer has chosen Scissors (Dont display the computer's choice yet) 2. The user enters his or her choice of “Rock”, “Paper", “Scissors" at...

  • COP2221 - Intermediate C++ Programming Module #6 Assignment One 20 points This assignment refers to Learning...

    COP2221 - Intermediate C++ Programming Module #6 Assignment One 20 points This assignment refers to Learning Outcome #2: Create and utilize arrays to store lists of related data Programming Problem You have been hired to create a C++ program to simulate the lottery. Your program allows users to see how often their lottery number choices match a randomly generated set of numbers used to pick lottery winners. The company, "How Lucky Are You?, Inc." wants a modular, professional and user-friendly...

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