PyCon intro tutorial/Python scripts2

From OpenHatch wiki
Revision as of 15:41, 9 April 2014 by imported>Jesstess (Created page with "__NOTOC__ == Step #1: learn about dictionaries == == Review the state capitals quizzer == Review a useful script synthesizes a number of useful concepts that we've covered....")
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)


Step #1: learn about dictionaries

Review the state capitals quizzer

Review a useful script synthesizes a number of useful concepts that we've covered.

  1. Download the script state_capitals.py 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. Think about these questions:
    • Why do we use a dictionary to store the states and capitals?
    • What is the purpose of the variable i in the for loop?
    • What is the purpose of the input function?
    • Think about one way that you could extend the script to make it more useful. How would you make that change in code?