1. Learn
  2. /
  3. Courses
  4. /
  5. Intermediate Python for Data Science

Connected

Exercise

Simulate multiple walks

A single random walk is one thing, but that doesn't tell you if you have a good chance at winning the bet.

To get an idea about how big your chances are of reaching 60 steps, you can repeatedly simulate the random walk and collect the results. That's exactly what you'll do in this exercise.

The sample code already puts you in the right direction. Another for loop is wrapped around the code you already wrote. It's up to you to add some bits and pieces to make sure all results are recorded correctly.

Instructions

100 XP
  • Initialize all_walks to an empty list.
  • Fill in the specification of the for loop so that the random walk is simulated 10 times.
  • At the end of the top-level for loop, append random_walk to the all_walks list.
  • Finally, after the top-level for loop, print out all_walks.