Skillshare intro to Python/Unit 4: Difference between revisions

no edit summary
imported>Jesstess
imported>Jesstess
No edit summary
Line 1:
== Goal #1: using modules ==
 
To get some more practice with the <code>random</code> module, we're going to read, run, and extend some Python scripts that use this module.
foo
 
For each of the following Python scripts, please do the following:
 
<ol>
<li>Download the script and save it to your Desktop. Be sure to save it as a <code>.py</code> file.</li>
<li>Open the script in your text editor.</li>
<li>Read through the script. Answer these questions:
 
<ul>
<li>Overall, what does this script do?</li>
<li>What variables and data types are used? Where are the strings, integers, and floats?</li>
<li>What functions from the <code>random</code> module are used, and why?</li>
<li>Where are the comments, and what do they tell you?</li>
</ul>
</li>
<li>Once you have a good sense of what the script does, open a terminal, navigate to the directory where you saved the script, and run it. Does it do what you expected?</li>
</ol>
 
<b>Here are you scripts to read and run</b>. Have fun with them!
 
* [http://web.mit.edu/jesstess/www/SkillsharePython/Unit4/die.py nobel.py]
* [http://web.mit.edu/jesstess/www/SkillsharePython/Unit4/password_generator password_generator.py]
 
For <code>die.py</code>, how would you change the program to simulate rolling 2 dices?
 
For <code>password_generator.py</code>, how would you generate a password that was, instead of a fixed 10 characters long, a random length between 10 and 14 characters?
 
 
==Success!==
Anonymous user