Boston Python workshop/Saturday/ColorWall: Difference between revisions

no edit summary
imported>Jesstess
No edit summary
imported>Jesstess
No edit summary
Line 94:
 
<pre>python run.py RainbowTest</pre>
 
 
=== 5. Play with the randomness in <code>Twinkle</code> ===
 
Walk through <code>Twinkle</code>. Find explanations of the <code>random.randint</code> and <code>random.uniform</code> functions in the online documentation at http://docs.python.org/library/random.html.
 
Experiment with these functions at a Python prompt:
 
<pre>
import random
random.randint(0, 1)
random.randint(0, 5)
random.uniform(-1, 1)
</pre>
 
Then experiment with the numbers that make up the hue and re-run the effect:
 
<pre>
python run.py Twinkle
</pre>
 
<b>Challenge</b>: make <code>Twinkle</code> twinkle with shades of red.
 
 
Line 129 ⟶ 151:
Each column that we see on the wall corresponds to a <code>Column</code> object. Add some randomness to the color used by each column (the variable whose value you changed above) using the <code>random.random</code> function, re-run the effect, and see what happens.
</li>
<li>
Walk through <code>Twinkle</code>. Find explanations of the <code>random.randint</code> and <code>random.uniform</code> functions in the online documentation at
 
http://docs.python.org/library/random.html.
 
Experiment with these functions at a Python prompt:
 
<pre>
import random
random.randint(0, 1)
random.randint(0, 5)
random.uniform(-1, 1)
</pre>
 
Then experiment with the numbers that make up the hue and re-run the effect:
 
<pre>
python run.py Twinkle
</pre>
</li>
<li>
Write your own effects!
</li>
Anonymous user