Ask your own question, for FREE!
MIT 6.189 A Gentle Introduction to Programming Using Python (OCW) 8 Online
OpenStudy (anonymous):

Anyone doing the Conway's Game of Life? I've started on that and am understanding what is going on with the code provided (*I think*), but am unsure of how to get the random blocks. I tried a for loop to go through the dictionary of block_list, but nothing happens. Any ideas? Here's what I have: for blocks in range(len(self.block_list)): for squares in range(len(self.canvas)): block = Block(Point(x, y), 'red')

OpenStudy (anonymous):

I haven't tried this exercise myself, but think that all your code will only create block objects and then do nothing with them. What you probably want is random numbers picked from each range, up to the number of points you require, with those blocks in an array? Something like: import random randomPoints = 4 blocks = [] for dummy in range(randomPoints): self.block_list[random.randrange(len(self.block_list)] = # whatever a red point is ... or something like that, this would randomly select 4 points, say and set them to red. Hope this helps

OpenStudy (anonymous):

which is that from?

OpenStudy (anonymous):

unknon wn

Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!
Can't find your answer? Make a FREE account and ask your own questions, OR help others and earn volunteer hours!

Join our real-time social learning platform and learn together with your friends!