Python 101 - Section Overview
Introduction
This section serves as “ground zero” for learning the Python scripting language; no previous coding experience is necessary or expected. We’ll cover why learning a coding language is useful and why Python is an exceptional coding language to learn. And then we’ll dive in, exploring the very basics of writing Python code and what it can do. The ideas and concepts presented here won’t likely make you a proficient Python coder - that only comes with lots of practice and experience - but they should provide you with a solid foundation for exploring and learning more on your own.
The structure of this section is a bit different in that it involves exercises at the end of each subject covered. Again, proficiency with Python comes from practice and these exercises are a way of getting more practice, but they also allow me to gage your progress and identify and fix any confusion you may have on various topics.
Section organization & learning outcomes
Section | Learning Objectives |
---|---|
1. Introducing Python | • Start Python and run a simple Python command • Explain the advantages of Python for geospatial analysis • Describe how Python is related to other coding languages, like R |
2. Navigating Jupyter Notebooks | • Start a Jupyter Notebook session via a Python command line • Create a Windows shortcut to run Jupyter in a specific location • Create/open, edit, and save a notebook document • Explain what kernels are and how they are used • Write and execute Python in a Jupyter code cell • Create and format text in a Jupyter markdown cell • Save and share notebooks as .ipynb files as as .html files |
3. Getting started with Python | • List the basic elements of Python syntax • Define and use variables in Python • Reveal the value of a variable with print() • Reveal the data type of a variable with type() • Explain the concept of data type and its importance in Python • List Python’s simple data objects and explain how each is used • Locate documentation for Python objects • Manipulate string objects via their methods • Coerce or cast variables from one data type into another |
4. Python data structures | • Describe Python’s 4 basic data structures and how they differ • Store, modify, and query values stored in a Python list • Use index values to extract single elements and slices of elements from a list • Manipulate a string using list methods • Store and access values using Python tuples • Describe what “immutability” is and how it relates to Python tuples • Convert a list into a set object and use set methods to compare collections • Store and access values stored in Python dictionary • Explain the concept of key :value pairs with respect to Dictionaries• Add and update values stored in a dictionary • Print formatted values of variables in the context of other strings • Use Python’s escaping character to enable special behavior in strings |
5. Flow control in Python code | • Conditionally execute code blocks using if statements• Iterate code blocks using for loops• Iterate code blocks using while loops• Fine tune loops with break and continue • Define functions and use them in your code |
Reference Materials
You’ll find countless on-line tutorials, video lessons, and books on Python. I’ve found that the following resources stand out for getting one up to speed quickly on the basics of Python:
♦ Jake VanderPlas - Whirlwind Tour of Python resources
Jake VanderPlas’ Whirlwind Tour of Python is concise, logical, understandable, and best of all free!
- Book: http://www.oreilly.com/programming/free/a-whirlwind-tour-of-python.csp
- Free PDF: https://s3-us-west-2.amazonaws.com/python-notes/a-whirlwind-tour-of-python-2.pdf
- Interactive: https://mybinder.org/v2/gh/jakevdp/WhirlwindTourOfPython/master?filepath=Index.ipynb
- GitHub: https://github.com/jakevdp/WhirlwindTourOfPython
♦ Jason Briggs - Python for Kids
Another book I’ve found better than most is Jason Briggs’ Python for Kids, which makes some fairly complex, novel concepts entirely accessible - much better than some of the more dense, developer-centric books I’ve seen. This book, while not free, is fairly inexpensive.
- Home page: https://nostarch.com/pythonforkids
- Amazon: https://www.amazon.com/Python-Kids-Playful-Introduction-Programming/dp/1593274076
♦ On-line tutorials and courses
- Python for Everybody: https://www.py4e.com/
- W3Schools.com: https://www.w3schools.com/python/python_syntax.asp
- TutorialsPoint.com https://www.tutorialspoint.com/python/
- DataCamp.com (free, but account required): https://www.datacamp.com/courses/intro-to-python-for-data-science
- LinkedIn Learning (free for Duke affiliates, but lessons are a bit long…) https://www.linkedin.com/learning/