About the example code
Time for a little intermission. During this course, you will get to see a lot of example code. This example code can take on several forms. The most simple form is in-line code, like this: you can print text with print('Hello')
.
What youβll see more often, and have seen in the previous topics, is code where Iβm showing you what to do in the Python REPL:
>>> 1 + 1 2 >>> print('Hello') Hello
The REPLβs prompt looks like this: >>>
. I copy this prompt into the examples to make it clear that this code should be entered in the REPL.
Other times, Iβll show you Python code outside of a REPL too, e.g.:
# A comment print("Hello")
The obvious difference here is that the REPL prompt is missing from these examples. It makes it easier for you to copy and paste the code into your editor or REPL.
The most fun examples will use a pet project of mine, crumb.sh. These examples contain code that you can both modify and run. Some examples even include multiple files or little assignments. Below you can find an example of a crumb. Feel free to play around with it by editing and running the example:
About syntax highlighting
Example code in this course will almost always be syntax highlighted, meaning that the code is colored to make it easier to read. The website does this syntax highlighting, so itβs important to realize that your code might look different. Especially in the first sections of this course, your code wonβt have syntax highlighting at all. Once you start using an IDE (youβll learn all about it in this course) you too will have syntax highlighting on your computer.