Recent content by dkens
-
D
Python Python Help for CSC131: Random Walk Simulation
You're welcome. I'm new to this language myself but it seems to be a great language to learn programming with. Good luck on your future assignments.- dkens
- Post #7
- Forum: Programming and Computer Science
-
D
Python Python Help for CSC131: Random Walk Simulation
Slightly altered to cover the event where you step off the right (position 11) and the code produces and error (index out of range) or off the left and the code wraps around to the right in the list Should work fine now. import random times = [0] * 11 loc = 5 times[5] = 1 track_steps = 0...- dkens
- Post #5
- Forum: Programming and Computer Science
-
D
Python Python Help for CSC131: Random Walk Simulation
Here you go: Works in Python 2.7 import random times = [0] * 11 loc = 5 times[5] = 1 steps = 0 while 0 <= loc <= 10: step = random.randint(0,1) if step == 0: loc -= 1 print 'Moving left to location', loc else: loc += 1 print...- dkens
- Post #4
- Forum: Programming and Computer Science
-
D
Python Python Help for CSC131: Random Walk Simulation
Python can be much simpler than the above... let me put something here (when I figure out how to add code to the messages in this forum)- dkens
- Post #3
- Forum: Programming and Computer Science