Skillshare intro to Python/Unit 4

< Skillshare intro to Python
Revision as of 06:44, 13 June 2013 by imported>Jesstess

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?
    • Where are the comments, and what do they tell you?
  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, how would you change the program to simulate rolling 2 dices?

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


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