Python's Not (Just) For Unicorns

An interactive introduction to programming in Python, for human beings and whoever else

Chapter 9

Introduction to projects

Get excited for your very first project!

Projects are coding exercises meant to help you practice your new skills and show you what you’re now capable of. Everything we’ve done so far is pretty small and tiny, but now you’ll have the opportunity to tackle some larger projects1.

Now, we aren’t at exciting things yet, but they’ll get bigger and better as we learn more.

Using the editor

Using the console to write big projects is kind of tough, so we’re going to change tactics. I’ve written some code in the box below. Click the Run Python code button to, yes, run the Python code. You’ll see the results in the other box.

name = "Dr. Naples"

print("Hello", name, "how are you?")
print("Would you like some tea?")

Hooray! Beautiful magic! Nice right? Compared to using the console, this style is a little more like writing a full Python program. Let’s call it an editor. Starting now, sometimes we’ll use the editor and sometimes we’ll use the console.

Editors are nice because they let you write multiple lines of code at a time, add spacing, and look at those fun colors! That’s called syntax highlighting, and it helps you keep track of your code. Notice how strings and variables are different colors - tricks like that will eventually help you spot errors.

How to get good at projects

Repeat the project! This is the most important advice I can give you. The first time, feel free to use all of the hints and just try to complete the project. Then come back an hour later and try it again, only using the hints when you need them. Keep repeating the process until you can complete the project without any errors and without using hints.

Work one piece at a time. Instead of trying to write your code all at once, go step by step. If you need to get input from the user and print out a calculation, start by getting input and making sure it works. Then make the calculation, see if it works. Then add in printing out the result. This helps you from drowning in errors and extra lines of code.

Feel free to skip them! Some projects get people excited, and some projects make you boooored. If you don’t enjoy a project and think you have a good handle on the material, no problem - just keep going to the next chapter!

[1] Well, our first few projects aren’t very big, but they’ll get bigger, I promise