Expert answer:Python Functions HW

Solved by verified expert:Needing assistance on explanation and how to come across this problem.As a reminder, the game is played as follows: roll a six sided die. If you roll a 1, 2 or a 3, the game is over. If you roll a 4, 5, or 6, you win that many dollars ($4, $5, or $6), and then roll again. With each additional roll, you have the chance to win more money, or you might roll a game-ending 1, 2, or 3, at which time the game is over and you keep whatever winnings you have accumulated.Write three functions for the dice game as well as a main function.The welcome function has no arguments and no return value. It simply prints a brief welcome to the player.The rollDie function has one argument, sides, with sides having a default value of 6. The function uses randint, and returns the value of the die roll.The playGame function has one argument, runs, which represents how many iterations of the simulation should be performed. The function has no return, but it has the bulk of the code needed to play the game, including the printing of results (average and largest winnings). This function should call the welcome function and the rollDie function (let the function use the default number of sides).Test by calling playGame from main, specifying 10000 runs.
test.docx

Unformatted Attachment Preview

import random
input(‘Press “enter” to roll the dice’)
n = 10000#Run 10,000 simulations of the game
dollar = 0
for i in range(n):
#—–single game start——-#
die = random.randint(1, 6) #randint function from Python’s random module to get a die roll
result
print (die)
if die == 1 or die == 2 or die == 3:
print(“Game Over”)
break
elif die == 4:
dollar += 4
elif die == 5:
dollar += 5
elif die == 6:
dollar += 6
#—–end of single game——#
# dollar #accumulated during the game
#i equals to the number of counts
if dollar < 0 or i < 0: print('The average amount won is: ', 0) # since count start from 0 add one to get the actual count print('The largest amount won is: ', dollar) # since count start from 0 add one to get the actual count else: avg = dollar / (i+1) # average amount won print('The average amount won is: $', avg ) # since count start from 0 add one to get the actual count print('The largest amount won is: $', round(dollar,2)) # since count start from 0 add one to get the actual count ... Purchase answer to see full attachment

How it works

  1. Paste your instructions in the instructions box. You can also attach an instructions file
  2. Select the writer category, deadline, education level and review the instructions 
  3. Make a payment for the order to be assignment to a writer
  4.  Download the paper after the writer uploads it 

Will the writer plagiarize my essay?

You will get a plagiarism-free paper and you can get an originality report upon request.

Is this service safe?

All the personal information is confidential and we have 100% safe payment methods. We also guarantee good grades

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 20% with the discount code ESSAYHELP