Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

[Use Python ] Because of the great reduction in the number of oversea traveller recently a resort hotel wishes to attract more local customers and

[Use Python]

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.

Please use the below code:

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]))

Modify the program so that it generates the statistics of the probability of winning after playing the Go-Up game 100000 times. An example of the program output is given below. Note that because of the random nature of dice rolling, the statistics shown on your computer may differ.

Output:

image text in transcribed

============================================================================

Q2

[Use Python]

image text in transcribed

Probability of Go-Up Winning frequency is 3255 and the probability is 0.03255 Losing frequency is 96745 and the probability is 0.96745 The office where Doris is working is making her uncomfortable that sometimes it feels hot and other times feeling cold. Doris is interested in finding out the variations of temperature in her office during the 10 working hours. Help her to write a program that reads in the hourly temperatures into a list and does these tasks. Read the 10 samples of hourly temperatures into a list. Add input data validation to ensure the data is a floating point value between -20 and +50 (inclusive). Add code to find out and print the maximum and minimum temperature. Add code to find out and print the average temperature. Add code to print how many hours are above the average temperature. Hint: the program should first find the average and then traverse through the list again to find how many hours are above the average. For input validation, the program should print 'Please enter a number between -20 and +50" if the input does not fall within the specified range. The following shows an example execution of the program. Enter temperature of hour 1: 20.5 Enter temperature of hour 2: 21 Enter temperature of hour 3: A Please enter a number between -20 and +50 Enter temperature of hour 3: Please enter a number between -20 and +50 Enter temperature of hour 3: -25 Please enter a number between -20 and +50 Enter temperature of hour 3: 22 Enter temperature of hour 4: 25 Enter temperature of hour 5: 25.5 Enter temperature of hour 6: 26 Enter temperature of hour 7: 25 Enter temperature of hour 8: 25 Enter temperature of hour 9: 23 Enter temperature of hour 10: 20 The highest temperature is 26.0 The lowest temperature is 20.0 The average temperature is 23.3 The number of hours above average is 5

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

Oracle PL/SQL Programming Database Management Systems

Authors: Steven Feuerstein

1st Edition

978-1565921429

Students also viewed these Databases questions

Question

=+3 In what ways can an MNE improve or change its approach to IHRM?

Answered: 1 week ago