Question: B) Write a Python program for this question Because of the great reduction in the number of oversea traveller recently a resort hotel wishes to

B) Write a Python program for this question

Because of the great reduction in the number of oversea traveller recently a resort hotel wishes to attract more local customers and to start a new promotion campaign. At check-in, a customer would play a game called Go-Up, which involves rolling a 6-face die at most 5 times, and the customer would win a cash prize if the second time is not smaller than the first time, and the third time is not smaller than the second time, and similarly for the fourth time and the fifth time.

For example, the customer wins if the rolls are 3, 5, 5, 6, and 6, and the customer loses if the rolls are 3 and 2 (i.e. no need to consider the third roll).

In order to determine the amount of cash prize, the management wishes to know the probability (i.e. percentage of all cases) that a person could win. A simulation of playing the game many times is needed to estimate the probability. Each time, the program simulates the rolling of a die in Go-Up and find out whether the outcome is winning or losing.

The given code as below:

import random

freq = [0] * 7

for e in range(0, 100):

number = random.randint(1, 6)

freq[number] += 1

print('Num Freq')

for i in range(1, 7):

print(' {} {} '.format(i, freq[i]))

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!