top of page

07.06.2018: One Lesson of Python

Today's soundtrack is Lonely Island: "Popstar: Never Stop Never Stopping", an utterly disappointing album. The only track that I genuinely enjoyed was "Incredible Thoughts," which lampoons the /r/iamverysmart crowd. The album was well-produced technically, but the lyrics relied on potty humour and f-bombs in an attempt to elicit laughs. I really missed the witty lyricism that drew me to listen to Lonely Island in the first place, apparent on classics like "Jack Sparrow," "I'm On a Boat," and "We Like Sportz."

This afternoon, I'm working on chapter 1 of Al Sweigart's "Automate the Boring Stuff With Python," "Python Basics." I started by reviewing the order of operations in Python. We can use parentheses in math in Python as we do irl: (2+2)*4 = 16, but 2+2*4 = 10.

If we use the + command on two strings, it will combine them: 'Pop' + 'Star' = 'Popstar'. This is called string concatenation. We can also multiply a single string: 'Pop' * 2 = 'PopPop'.

Like I learned on my TI-83 Plus, in Python we can assign values to variables. We do so by simply saying the name of the variable, typing "=", and typing the number we want to assign to the variable. For example: "Top = 40" will give me the result "40" the next time I type "Top." We overwrite a variable by assigning another value to it in the same way.

When making a variable name, remember: "1. It can only be one word. 2. It can only use letters, numbers, and the underscore (_) character. 3. It can't begin with a number" (citation). They are also case-sensitive.

We use the file editor window to create programs. Inside the file editor, we can differentiate between strings and integers by preceding them with "int" or "str". Floating-point numbers are just "[n]umbers with a decimal point" (citation).


bottom of page