Python 3 latest code crumbs

Python modules

Python modules

Jan 25, 2022 by erik

You can import a Python module by using the import keyword. Module imports are often placed at the top of a script, but they don't have to be. E.g., sometimes you want to dynamically decide if you need to import...

import modules
Python Dictionary View Objects

Python Dictionary View Objects

Jan 21, 2022 by erik

Some built-in Python dictionary methods return a view object, offering a window on your dictionary's keys and values. There's an important concept you need to understand: values in a view object change as the content of the dictionary changes. In...

view-objects dictionary
Default values and named parameters

Default values and named parameters

Jan 16, 2022 by erik

A compelling Python feature is the ability to provide default values for the parameters. Because our parameters have a default value, you don't have to fill them in. If you don't, the default is used. If you do, you override...

default-values functions
While loop

While loop

Jan 16, 2022 by erik

While the for-loop in Python is a bit hard to understand, the while loop is actually much simpler! In this example, we see an expression that follows the while statement: i <= 4. As long as this expression evaluates to...

while-loop
Python for loop and lists

Python for loop and lists

Jan 16, 2022 by erik

A Python list can contain zero or more objects. It's a frequently used data type in Python programming. In other programming languages, lists are often called arrays. Python does not have arrays, though, only lists. We can loop, or iterate,...

for-loop list
The print function

The print function

Jan 16, 2022 by erik

The Python print function can print text to your screen. We can feed it one or more arguments, and these arguments will get printed on the screen. In its most basic form, we can call print without any argument. In...

print