Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Answer the question or perform the following exercises. For each exercise Copy and paste your scripts and functions into a word document along with the

image text in transcribed
Answer the question or perform the following exercises. For each exercise Copy and paste your scripts and functions into a word document along with the output. 1) Describe in words why the above looop will never end if x=0.09. 2) Perform the following tasks a) Write a function which generates a random number between 1 and 1000. Call the function rand_1000. This function doesn't take an input. b) Write a script which calls your rand_1000 function 10 times and sums the results. c) Write a script which initiatizes a variable x to some random number between 1 and 10000. Then repeatdely or iteratively update x by alternately adding a random number between 1 and 1000 followed by subtracting a random number between 1 and 2000. Stop when x 50. Output x to the screen each iteration. Make use of rand_1000 whenever possible to save work. d) Bonus points: The above function is random or stochastic. It will take a different number of iterations to exit each time you run it. What is the expected number of times it will run before it ends? In other words if you ran it a billion times, counted the number of iterations each time, and averaged them together what would it be

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

Database Design And Relational Theory Normal Forms And All That Jazz

Authors: Chris Date

1st Edition

1449328016, 978-1449328016

More Books

Students also viewed these Databases questions