Extras 1.2: Python Concepts
Statements vs. expressions
There is a subtle difference between expressions and statements. When we send an expression to Python interpreter, we are asking Python to evaluate the expression and return back a value. When we send a statement to Python interpreter, we are asking Python to do something (like assign a result of an expression to a variable).
The distinction between the two is often blurry and it’s not always immediately obvious whether a given instruction is an expression or a statement. At this level, we can simplify things a little bit and say that statements are instructions that do not return a value while expressions are instructions that do return a value.
Single and double quotation marks
As you may have noticed, the two print statements in Lesson 1.3 looked different. One is using double quotes, the other single quotes. Yet they output the same looking string! It turns out that there’s really no difference between the two types of quotation marks, you can use either one of them with the exact same behavior.
In some situations, however, it is easier to use one type of quotation marks instead of the other. For example, imagine that you want to print a string Sara’s pet. Try to use both single quotes and then double quotes. Do you see why we cannot use single quotes around the string Sara’s pet? Problem is that Python does not know that the single quote in Sara’s is in the middle of the string. It actually thinks that the string ends with Sara and, since it does not understand s pet, it returns a syntax error.
How to arrange your desktop
When we were writing our very first Python program in Lesson 1.3, we had two Python windows open plus a browser window. Not so easy to arrange nicely, especially on smaller laptops. You can arrange all of the windows however you like but it’s easier if they don’t overlap, since we will be switching from one window to another frequently.
One possible way to do the arrangement is to use Window Key + ← to have your browser with our website use left half of your screen. Then, you can manually resize and reposition the Python shell window in the upper half of the right half of your screen and resize hello.py window to use the bottom half of the right side. Essentially, you should have the following: