Skillshare intro to Python/Unit 5

From OpenHatch wiki
Revision as of 15:16, 13 June 2013 by imported>Jesstess

Goal #1: reading from files

To get some more practice with reading from files, we're going to read, run, and extend some Python scripts.

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!