Exercises for Real Python's "Python Basics: A Practical Introduction to Python 3" Book
If you have git installed, the easiest way to access these files is to clone the repository to the directory of your choice:
$ git clone https://github.com/realpython/python-basics-exercises.gitThen cd into the itertools-in-python3 directory:
$ cd materials/itertools-in-python3Alternatively, you can download the entire repository as a .zip file from the repository's homepage using the green "Clone or download" button in the top right hand corner.
To run the code examples, first make sure you have Python 3 installed on your machine. The code examples WILL NOT work with Python 2. If you need help installing Python 3, check out Real Python's Python 3 Installation & Setup Guide.
To run the sp500.py file, type python3 sp500.py into your terminal. Here's how that looks, with output:
$ python3 sp500.py Max gain: 11.58% on 2008-10-13 Max loss: -20.47% on 1987-10-19 Longest growth streak: 14 days (1971-03-26 to 1971-04-15)Note: Depending on your installation, you may need to type
python3.6orpython36to run the examples. If you follow the Python 3 Installation & Setup Guide, you should have no problem.
Similarly, for swimmers.py:
$ python3 swimmers.py Backstroke A: Sophia, Grace, Penelope, Addison Backstroke B: Elizabeth, Audrey, Emily, Aria Breaststroke A: Samantha, Avery, Layla, Zoe Breaststroke B: Lillian, Aria, Ava, Alexa Butterfly A: Audrey, Leah, Layla, Samantha Butterfly B: Alexa, Zoey, Emma, Madison Freestyle A: Aubrey, Emma, Olivia, Evelyn Freestyle B: Elizabeth, Zoe, Addison, Madison