1. How long will it take to compute the chance of doubling 1 million dollars one dollar at a time?

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...
icon
Related questions
Question

Can someone help me with this program in python?

Using this code how can I use the stopwatch module to filll out this table

 

Use the stopwatch  module to estimate how long your program runs. 

stake - initial amount you start with

goal - the amount you want to end with (you will either lose it all or make your goal)

trials - the number of times you want to run the experiment - run the experiment 100 times to get a more accurate estimate of the probability.  Do any empirical analysis using the doubling method.  Start with the stake = 500 and goal 1000 and continue to double until the stake = 1000000. 

TN
TN/ TN/2
500
1000
2000
4000
8000
Transcribed Image Text:TN TN/ TN/2 500 1000 2000 4000 8000
See the implementation of gambler.py . How long will it take to compute the chance of doubling 1 million dollars one dollar at a time?
2 gambler.py - C:\Users\ducep\OneDrive - The University of Montana\CSCI 151 Online\Module12\gambler.py (3.9.6)
File Edit Format Run Options Window Help
import stdio
import sys |
import random
def main():
= int (sys.argv[1])
= int (sys.argv[2])
int (sys.argv[3])
stake
goal
trials
wins
= 0
for t in range(0,trials):
cash = stake
while (cash > 0 and cash < goal):
if (random.random() < 0.5):
cash += 1
else:
cash
1
if (cash
stdio.writeln(str(wins) +
goal): wins += 1
==
wins of
+ str(trials) )
if
main
': main()
name
Ln: 2 Col: 11
Transcribed Image Text:See the implementation of gambler.py . How long will it take to compute the chance of doubling 1 million dollars one dollar at a time? 2 gambler.py - C:\Users\ducep\OneDrive - The University of Montana\CSCI 151 Online\Module12\gambler.py (3.9.6) File Edit Format Run Options Window Help import stdio import sys | import random def main(): = int (sys.argv[1]) = int (sys.argv[2]) int (sys.argv[3]) stake goal trials wins = 0 for t in range(0,trials): cash = stake while (cash > 0 and cash < goal): if (random.random() < 0.5): cash += 1 else: cash 1 if (cash stdio.writeln(str(wins) + goal): wins += 1 == wins of + str(trials) ) if main ': main() name Ln: 2 Col: 11
Expert Solution
trending now

Trending now

This is a popular solution!

steps

Step by step

Solved in 2 steps

Blurred answer
Follow-up Questions
Read through expert solutions to related follow-up questions below.
Follow-up Question

So how long in seconds will it tak to compute 5000 dollars and then one milllion dollars

Solution
Bartleby Expert
SEE SOLUTION
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
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 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)
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
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY