1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
allsm [11]
3 years ago
8

A slot machine is a gambling device that the user inserts money into and then pulls a lever (or presses a button). The slot mach

ine then displays a set of random images. If two or more of the images match, the user wins an amount of money that the slot machine dispenses back to the user. Design a program that simulates a slot machine. When the program runs, it should do the following: Ask the user to enter the amount of money he or she wants to insert into the slot machine. Instead of displaying images, the program will randomly select a word from the following list: Cherries, Oranges, Plums, Bells, Melons, Bars The program will select and display a word from this list three times. If none of the randomly selected words match, the program will inform the user that he or she has won $0. If two of the words match, the program will inform the user he or she has won two times the amount entered. If three of the words match, the program will inform the user that he or she has won three times the amount entered. The program will ask whether the user wants to play again. If so, these steps are repeated. If not, the program displays the total amount of money entered into the slot machine and the total amount won.
Computers and Technology
1 answer:
postnew [5]3 years ago
4 0

Answer:

import random

is_cont = 'y'

amount = float(input("Enter amount: "))

total = 0.0

slot = ['Cherries', 'Oranges', 'Plums', 'Bells', 'Melons', 'Bars']

while is_cont == 'y':

   hold = []

   for i in range(3):

       ent = random.choice(slot)

       print(ent)

       hold.append(ent)

   if hold.count(hold[0]) == 3 or hold.count(hold[1]) == 3 or hold.count(hold[2]) == 3:

       print(f"{3 * amount}")

       total += 3 * amount

   elif hold.count(hold[0]) == 2 or hold.count(hold[1]) == 2 or hold.count(hold[2]) == 2:

       print(f"{2 * amount}")

       total += 2 * amount

   else:

       print("$ 0")

   is_cont = input("Try again? y/ n: ")

Explanation:

The python program is in a constant loop so long as the 'is_cont' variable has a value of 'y'. The program implements a slot machine as it gets an amount of money from the player and randomly selects an item from the slot list variable three times.

If all three selections match, the player gets three times the amount paid and if two items match, then the player gets twice the pay but gets nothing if all three items are different.

You might be interested in
What are some causes of the number of bytes on the wire exceeding the number of bytes being captured?
Aneli [31]
<span>Some causes of the number of bytes on the wire exceeding the number of bytes being captured is that </span>not everything is being captured or that partial packets may be captured which could lead to incorrect analysis. If there are regularly more bytes on the wire than captured, then, it is possible that the computer on which Wireshark is running is not able to keep up with the interface.
7 0
3 years ago
Read 2 more answers
The \t and \n are examples of one of Python's escape characters.<br><br> A. True<br> B. False
natali 33 [55]

Answer:

A. true

Explanation:

Step 1: int fun(int); This is prototype of function fun().It tells the compiler that the function fun() accept one integer parameter and returns an integer value.. Step 2: int i=3; The variable i

4 0
2 years ago
Which term is defined as an exploit that takes place before the security community or software developer knows about the vulnera
Natasha_Volkova [10]

Answer:

A zero-day attack.

Explanation:

A Zero-day vulnerability is a computer-software vulnerability that is unknown to, or unaddressed by, the security community or software developer or even the vendor of the target software. Until the vulnerability is mitigated, hackers can exploit it to adversely affect computer programs, data, additional computers or a network.

An exploit directed at a software with zero-day vulnerability & exploiting this vulnerability is called a zero-day exploit, or zero-day attack.

3 0
3 years ago
How do you change colors for presentation to blue warm in power point?
Furkat [3]

In PowerPoint presentations you can change background color. The best way to do this is to change the template background color in the master view. This will let you use the same background color among the whole presentation and also for the new slides that you will create.

In order to change the background color in Microsoft PowerPoint 2010 we need to go to View and Slide Master. Then, right click on the first slide and click Format Background.

5 0
3 years ago
April 107 90 29 31 66 0.344
Misha Larkins [42]

Answer:

Check the explanation

Explanation:

with open('stats. txt', 'r') as   # open the file in read mode

   list1 = []   # initialize an empty list

   for i in  . readlines ():  # read every line of file

       for j in i. split ():  # split each line by a space and append it to the list1

           list1. append (j)

   months = [] # initialize required lists to empty list

plate_apperence = []

at_bats = []

runs = []

hits = []

total_bats = []

for i in range(0, len(list1)-1, 7): # use a for loop and give parameters as start,stop and step count

months. append(list1[i]) # append list1 elements to required lists

plate_apperence. append(int(list1[i+1]))

at_bats. append(int(list1[i+2]))

runs. append(int(list1[i+3]))

hits. append(int(list1[i+4]))

total_bats. append(int(list1[i+5]))

for i in range(len(months)): # for each element in months

print("Player's Average Batting and slugging percent for the month ", months[i], " is as shown below")

print("{:.2f}".format(hits[i]/at_bats[i])) # calculate Average batting and slugging percent and print them

print("{:.2f}". format(total_bats[i]/at_bats[i]))

print("\n")

Kindly check the attached images below to get the Code Screenshot and Code Output.

3 0
3 years ago
Other questions:
  • The photo-sharing site Instagram owed a good deal of its success to filters. What are filters?
    11·2 answers
  • What New England industry quickly collapsed with the discovery of oil in Pennsylvania?
    11·2 answers
  • 642<br> +277<br> What does 642+277
    7·1 answer
  • How do you change brightness on acer laptop?
    7·1 answer
  • Write a declaration for a class named City, which has the members cityName, a string, and position, a Location structure (declar
    10·1 answer
  • What is related to Gamut in Adobe illustrator?
    8·1 answer
  • Write a program called DeliveryCharges for the package delivery service in Exercise 4. The program should again use an array tha
    9·1 answer
  • What is a good starting point for data mining?
    5·1 answer
  • A thesis statement is the last sentence of the conclusion. It summarizes the entire paper.
    13·1 answer
  • What type of attack occurs when the threat actor snoops and intercepts the digital data transmitted by the computer and resends
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!