Mini program - after the quiz Simulate a spinner game. 3 2 Simulate a spinner with the numbers 1-8 on it. If it is a 7 or 8 the person wins. Chances to spin each number are equal. 4 Run the game 100 times and put all results in a list called results[] 8 Print list of values 6 7 Calculate 1) The average score 2) Find totals of each number and store them in a list or Dictionary 3) Print totals Use the totals to find the following 4) The most common score and state how many of them there were. 5) How many wins (number of 7's and 8's) 6) The experimental probability of each number, which is their total/100 *100 The theoretical probability is 12.5% =
Mini program - after the quiz Simulate a spinner game. 3 2 Simulate a spinner with the numbers 1-8 on it. If it is a 7 or 8 the person wins. Chances to spin each number are equal. 4 Run the game 100 times and put all results in a list called results[] 8 Print list of values 6 7 Calculate 1) The average score 2) Find totals of each number and store them in a list or Dictionary 3) Print totals Use the totals to find the following 4) The most common score and state how many of them there were. 5) How many wins (number of 7's and 8's) 6) The experimental probability of each number, which is their total/100 *100 The theoretical probability is 12.5% =
Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
Related questions
Question
Hello, Im in AP computer science principles in high school. Im trying to code this
Expert Solution
Step 1
The python program which answer all the parts is given below. The print outputs are self-explanatory:
import random
result = []
score = 0
for i in range(100):
output = random.randint(1,8)
result.append(output)
if output in [7,8]:
score += 1
average_score = score/100
print("The numbers from each spin:")
print(result)
#1
print("Average score: {}".format(average_score))
#2
dict_totals = dict(zip(range(1,9),[0]*8))
def switch_case(x):
if x == 1:
dict_totals[1] += 1
elif x == 2:
dict_totals[2] += 1
elif x == 3:
dict_totals[3] += 1
elif x == 4:
dict_totals[4] += 1
elif x == 5:
dict_totals[5] += 1
elif x == 6:
dict_totals[6] += 1
elif x == 7:
dict_totals[7] += 1
elif x == 8:
dict_totals[8] += 1
[switch_case(x) for x in result]
#3
print("Totals of each number:")
print(dict_totals)
#4 - first part
max_count = max(dict_totals.values())
print("Most common score: {}".format(max_count))
#4 - second part
count_max = 0
for x,y in dict_totals.items():
if y == max_count:
count_max += 1
print("Total number of most common score: {}".format(count_max))
#5
print("Number of wins: {}".format(dict_totals[7]+dict_totals[8]))
#6
for x,y in dict_totals.items():
percent = round((dict_totals[x]/100)*100,2)
print("Percentage for {} is {}".format(x,percent))
Trending now
This is a popular solution!
Step by step
Solved in 3 steps with 1 images
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY