1. Consider a device that consists of a vertical board with evenly spaced page as shown below:...
Question:
1. Consider a device that consists of a vertical board with evenly spaced page as shown below: Balls dropped from the opening at the top of the board and move
to the left or right as they hit a peg. A ball has a 50% chance of falling to the left or right at each peg. Write a Python program, in a file called counter. py, to simulate this device, asking the user for the number of balls and the number of slots in the board. Your program, in a file called counter. py, to simulate this device, asking the user for the number of balls and the number of slots in the board. Your program should output the path of each ball in the form of a string of Ls and Rs and the slotnumber that ends ball falls into. Note that the slot that a ball falls into is equal to the number of "R"s in the path string. After the path of all balls have been determined, your program should output a histogram of the slots. Divide your solution into separate functions. for example: a function to compute a path string for a ball given the number of slots (you can make use of the random function to generate random values between 0 and 1); a function to determine the slot number given a path string (do not use the count method); and a function to output a histogram. Hint: Use a list to keep track of how many balls arc in each slot.
Sample input/output:
Enter number of balls: 10