Video

Lesson 3

After watching the lesson, try the mini assignment at the end.

I forget to mention in the video that you can also compare strings with relational operators >, <, <=, >=,!=, ==

'apple' < 'banana'  #True
'cat' == 'cat'  #True
4 < 2  #False

So strings are compared alphabetically and integers are compared numerically.

It can be very dangerous to compare floating point number with equality (==). Because sometimes 3.0 != 3.000000001. So == should not be used for floating point numbers.

Interpreter vs Programs

In the interpreter commands like

3+6

will instantly give you the result. However, that line in an actual program would do nothing as you are not saving the result to a variable. So in a program it could be:

answer=3+6   #the sum is stored in variable "answer"

and if you want the variable to be printed:

print(answer)