Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Instructions: Slot Machine: Were going to create a game that generates 3 random numbers, each between 1 and 10, checks to see if any of

Instructions: Slot Machine: Were going to create a game that generates 3 random numbers, each between 1 and 10, checks to see if any of the numbers match and then tells the user what they've won Each time the user plays, the game should ask if they would like to play again. The game should repeat until the user says he does not want to play again If the user matches all 3 mumbers, the game should print: "You've hit the Jackpot!" If the user matches 2 out of 3 mumbers, the game should print: "You've matched 2!" If the user doesn't match any numbers, the game should print "Sorry. Better luck next time." In order to create this game, we are going to use the random.randint) function from the random module provided in Python At the top of your source file, add the following import statement import random 2 After importing, before you perform any other action, include the following statement random.seed) this will seed the random number generator so we can start to get pseudo-random numbers from Python 3 Now, in order to generate a new number between 1 and 10, you will use the following code: first_number random.randint(1, 10) This code generates a random integer between the first and second argument, and stores it in the variable first_number. You will repeat that step for each of the remaining 2 numbers. 4. Use a while loop to allow us to play the game repeatedly 5. After each round, ask the user if they would like to play again. They should enter Y for yes, and N for no (All uppercase for now). This should form your Loop Control Expression To check if two strings are equal in python, we use the ==' operator as follows if answer== "Y": print( "You entered "Y') et LO

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

App Inventor

Authors: David Wolber, Hal Abelson

1st Edition

1449397484, 9781449397487

More Books

Students also viewed these Programming questions