Category Archives: Education

Python in education, from Kindergarten through college. The article will probably be about teaching Python.

Educative Python Courses on Sale for PyCon!

I am putting my interactive Educative Python courses on Sale for PyCon this week. You can get Python 101 and Python 201: Intermediate Python for 50% off. Here are the coupon codes you can use:

Educative is also doing a 50% off sale on their Python 3: An interactive deep dive course which you can get with this coupon: au-pycon-deepdive.

And now for something completely different, Educative is offering a 17% off sale of their Coderust 2.0: Faster Coding Interview Preparation using Interactive Visualizations, so if you are interested in learning something a little different, now is your chance! Here’s the code for that: au-pycon-coderust

Python 101: All About Dictionaries

The Python programming language has several built-in types that it supports. One of my favorites is the dictionary. A dictionary is a mapping object maps hashable values to arbitrary objects (source). Other languages call dictionaries “hash tables”. They are mutable objects that you can change whenever you want to, unlike tuples. A dictionary’s keys must be hashable or immutable, which means that you cannot use a list or another dictionary as a key. Note that dictionaries before Python 3.6 are not ordered. In Python 3.6, they changed the dict’s implementation so that it is now ordered, although there is a warning mentioned that you should not rely on it being ordered. What this means is that when you iterate over a dictionary, you may not extract the values in the same order that you inserted them except in Python 3.6 and potentially future versions of Python.

In this article, we will take some time learning about some of the many things you can do with a dictionary.


Creating Dictionaries

A dictionary is a key:value pair. In Python, these key:value pairs are enclosed inside of curly braces with commas between each pair. Creating dictionaries in Python is really easy. Here are the three ways to create a dictionary:

>>> my_dict = {}
>>> my_other_dict = dict()
>>> my_other_other_dict = {1: 'one', 2: 'two', 3: 'three'}

In the first example, we create an empty dictionary by just assigning our variable to a pair of empty curly braces. You can also create a dictionary object by calling Python’s built-in dict() keyword. I have seen some people mention that calling dict() is slightly slower than just doing the assignment operator. The last example shows how to create a dictionary with some predefined key:value pairs. You can have dictionaries that contain mappings of various types, including mapping to functions or objects. You can also nest dictionaries and lists inside your dictionaries!

Continue reading Python 101: All About Dictionaries

Python 101 is now a Course on Educative

My first book, Python 101, has been made into an online course on the educative website. Educative is kind of like Code Academy in that you can run the code snippets from the book to see what kind of output they produce. You can edit the examples that are executable, but you cannot save your edits currently. You can get 50% off of the course by using the following coupon code: au-pythonlibrary50 (note: This coupon is only good for one week)

Python 101 is for primarily aimed at people who have an understanding of programming concepts or who have programmed with another language already. I do have a lot of readers that are completely new to programming who have enjoyed the book too though. The book itself is split into 5 distinct parts:

Part one covers the basics of Python. Part two moves into learning a little of Python’s standard library. In this section, I cover the libraries that I find myself using the most on a day-to-day basis. Part three moves into intermediate level territory and covers various topics such as decorators, debugging, code profiling and testing your code. Part four introduces the reader to installing 3rd party libraries and briefly demonstrates some of the popular ones, such as lxml, requests, SQLAlchemy and virtualenv. The last section is all about distributing your code. Here you will learn how to add your code to Python Package Index as well as create Windows executables.

For a full table of contents, you can visit the book’s web page here. Educative also has a really good contents page for the online course too.

ANN: The Python by Example Udemy Course

I am happy to announce my first Udemy course on the Python programming language. It is called Python by Example and is a re-branding of my Python 101 Screencast series. I had originally hoped to keep the name, Python 101 on Udemy, but someone else had already taken it by the time I got my course started on there. Regardless, the course is made with the first 35 videos from the Python 101 Screencast. I plan to add the rest later this year.

py_by_example

What You Get

At the time of writing, you will receive 35 lectures or 6.5 hours of content. I have also included chapters from Python 101 that correspond with each lecture.

How to Purchase

To purchase Python by Example, just go to the following link: https://www.udemy.com/python-by-example/?couponCode=py25. The coupon code will give you 25% off.

Book Review: Python Projects for Kids

I get asked by publishers to review books from time to time. Last month, Packt asked me if I’d be willing to review for their book, Python Projects for Kids by Jessica Ingrassellino. Frankly I tend to avoid beginning Python books now because they tend to be very similar, but I thought this one might be interesting.


Quick Review

  • Why I picked it up: In this case, because Packt Publishing asked me to
  • Why I finished it: Mostly because Packt personnel badgered me to do so
  • I’d give it to: Not really sure. There are much better, more in-depth beginner books for Python out there

Continue reading Book Review: Python Projects for Kids

Python 101: An Intro to ftplib

The File Transfer Protocol (FTP) is used by many companies and organizations for sharing data. Python provides an File Transfer Protocol module in its standard library called ftplib that implements the client side of the FTP protocol. You can learn all about the File Transfer Protocol by reading the RFC 959 document on the Internet. However the full specification is outside the scope of this article. Instead we will focus on the following topics:

  • Connecting to an FTP server
  • Navigating it’s structure
  • Downloading files from the FTP server
  • Uploading files to an FTP server

Let’s get started!

Continue reading Python 101: An Intro to ftplib

Python 101: All about imports

One of the first items you learn as a beginner Python programmer is how to import other modules or packages. However, I’ve noticed that even people who have used Python casually for multiple years don’t always know how flexible Python’s importing infrastructure is. In this article, we will be looking at the following topics:

  • Regular imports
  • Using from
  • Relative imports
  • Optional imports
  • Local imports
  • import Pitfalls

Continue reading Python 101: All about imports

Free Intro to Python Course from Webucator

Webucator recently contacted me to let me know that they have finished up an Introduction to Python Training that they are allowing people to take for free for the month of February. The course is made up of videos, exercises, readings, and quizzes. You can get it free by using the following code when you register: PYTHON

I thought they did a good job when they did a video based on my context manager article.

Book Review: Python Playground – Geeky Projects for the Curious Programmer

No Starch Press recently sent me a book called Python Playground: Geeky Projects for the Curious Programmer by Mahesh Venkitachalam to review. I don’t normally get books from that publisher so I wasn’t sure what to expect, but the book is quite good. But I won’t provide any spoilers here as we have a quick review to do!


Quick Review

  • Why I picked it up: I got it for free, but the description of the book made me want to get it too.
  • Why I finished it: It’s very well written and the projects are definitely geeky and fun.
  • I’d give it to: A programmer who is also a math nerd or who just wants ideas for a new, fun project.

Continue reading Book Review: Python Playground – Geeky Projects for the Curious Programmer

eBook Review: Intermediate Python

I was recently approached by the author of the free eBook, Intermediate Python by Muhammad Yasoob Ullah Khalid to review his work. Yasoob is the fellow behind the Python Tips blog. The book has been released as open source on Github but can be downloaded as a PDF from ReadTheDocs. But before I go into too much detail about the book, here’s my quick review:


Quick Review

  • Why I picked it up: I was asked by the author to read the book.
  • Why I finished it: I read through a lot of the book and skimmed the rest, actually
  • I’d give it to: A beginner who wants to learn a bit more about the Python language

Continue reading eBook Review: Intermediate Python