Skillshare intro to Python/Unit 4: Difference between revisions

From OpenHatch wiki
imported>Jesstess
No edit summary
imported>Jesstess
Line 14: Line 14:
 
<li>What variables and data types are used? Where are the strings, integers, and floats?</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>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>
 
</ul>
 
</li>
 
</li>
Line 28: Line 27:
   
 
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?
 
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!==
 
==Success!==

Revision as of 06:44, 13 June 2013

Goal #1: using modules

To get some more practice with the random module, we're going to read, run, and extend some Python scripts that use this module.

For each of the following Python scripts, please do the following:

  1. Download the script and save it to your Desktop. Be sure to save it as a .py file.
  2. Open the script in your text editor.
  3. Read through the script. Answer these questions:
    • Overall, what does this script do?
    • What variables and data types are used? Where are the strings, integers, and floats?
    • What functions from the random module are used, and why?
  4. 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?

Here are you scripts to read and run. Have fun with them!

For die.py, how would you change the program to simulate rolling 2 dices?

For password_generator.py, how would you generate a password that was, instead of a fixed 10 characters long, a random length between 10 and 14 characters?

Success!

You have master lists and loops, two of the most important concepts in this course. Keep practicing!

Champagne.pngParty.png