Sydney Opera House sails during sunset.

100 Days of Python: Day 7

Today’s lesson comes from Python Program Lexical Structure. Python Statements Like the Ruby interpreter, the Python interpreter when loading a file loads the file one line at a time, executing the states of those lines accordingly, until the end-of-file is encountered. Line Continuation PEP 8: Maximum Line Length “limits” all lines to be no longer than 79 characters long, with the exception that docstrings/comments be limited to 72 characters in length....

March 16, 2021 · 2 min · Alan Scherger
Coffee next to a laptop

100 Days of Python: Day 6

Habit Building It turns out building new habits is hard. Without carving out purposeful time each day, it’s very easy to let new habits get swallowed by daily habits. It also seems important to let go of the guilt or failure of not meeting an immediate expectation and rather to keep reinforcing the good behavior. i.e. get back on the horse. So, here we are Day 6 ? whatever that means now 😂 and moving ahead....

March 15, 2021 · 2 min · Alan Scherger
Vibrant scenery at Joshua Tree National Park.

100 Days of Python: Day 5

Dictionaries Are: mutable keys must be hashable this meaning functions can actually be keys have fun methods like pop() and popitem() for removing keys support nesting don’t support nested membership tests 1 2 3 4 5 f = {1: 'value', len: 1, 'str': (1j-3) } self.assertEqual(f[1], 'value') self.assertEqual(type(f[1]), str ) self.assertEqual(type(f[len]), int ) self.assertEqual(type(f['str']), complex ) Sets Oh. boy. First class support for sets 🤩 wow, I’m so excited!...

February 25, 2021 · 2 min · Alan Scherger
Snow covered ground with white air balloons hovering

100 Days of Python: Day 4

Booleans We started the morning off with this article. True and False are also integers 1 and 0: 1 2 True == 1 False == 0 This means that can be used to count things with sum(). Python uses shortcutting when evaluating logical expressions, so if it already knows the answer, the other statements will never be executed. The is operator validates the identity of an object....

February 23, 2021 · 3 min · Alan Scherger
Homes off in the distance covered in snow.

100 Days of Python: Day 3

String slices Slices of string includes the first value and excludes the last value. Negative indexing works as well, but you still cannot “wrap around” the slice more than once. Striding allows you to skip values in an array, and negative striding lets you start at the end of the string and work backwards. Strings are immutable in Python, so you need to use slices of replace() to change them....

February 22, 2021 · 2 min · Alan Scherger