🦜 Python Morsels: Write better Python code
@www.pythonmorsels.com@rss-parrot.net
I'm an automated parrot! I relay a website's RSS feed to the Fediverse. Every time a new post appears in the feed, I toot about it. Follow me to get all new posts in your Mastodon timeline!
Brought to you by the RSS Parrot.
---
Adopt a more Pythonic coding style in 60 minutes of practice each week. Python Morsels includes exercises and screencasts by a professional Python trainer.
Your feed and you don't want it here? Just
e-mail the birb.
Creating Python programs
https://www.pythonmorsels.com/creating-python-programs/
Published: September 6, 2024 18:21
Python programs are created in code editors, and can be run using system command prompt.
Table of contents
The Python REPL
Definitions: program, script, command-line, editor
Creating a Python program in a code editor
…
Functions and Methods in Python
https://www.pythonmorsels.com/functions-and-methods/
Published: August 30, 2024 22:23
Methods are functions that live on objects.
Table of contents
Operators
Some functions included with Python
Calling functions
Function arguments
Functions either return a value or perform an action
…
Arithmetic in Python
https://www.pythonmorsels.com/arithmetic-in-python/
Published: August 28, 2024 21:10
An explanation of Python's two number types (integers and floating point numbers), supported arithmetic operations, and an explanation of operator precedence.
Table of contents
Integers
Floating point numbers
Mixing…
Checking for an empty list in Python
https://www.pythonmorsels.com/checking-for-an-empty-list-in-python/
Published: August 20, 2024 21:18
Python programmers typically check for empty lists by relying on truthiness.
Table of contents
Checking the length of a list
Evaluating the truthiness of a list
Comparing for equality with an empty list
Truthiness…
How to make a tuple
https://www.pythonmorsels.com/how-to-make-a-tuple/
Published: August 2, 2024 21:36
Tuples are technically just immutable lists, but by convention we tend to use tuples and lists for quite different purposes.
Table of contents
Making tuples in Python
Tuples are like lists, but immutable
Tuples are all…
Using "else" in a comprehension
https://www.pythonmorsels.com/comprehension-with-else/
Published: July 20, 2024 16:53
While list comprehesions in Python don't support the else keyword directly, conditional expressions can be embedded within list comprehension.
Table of contents
Do list comprehensions support else?
But else does work in…
What are lists in Python?
https://www.pythonmorsels.com/what-are-lists/
Published: July 12, 2024 15:09
Lists are used to store and manipulate an ordered collection of things.
Table of contents
Lists are ordered collections
Containment checking
Length
Modifying the contents of a list
Indexing: looking up items…
Strings in Python
https://www.pythonmorsels.com/strings-in-python/
Published: July 4, 2024 15:16
Strings are used to store text-based data.
Table of contents
Strings store text
How are strings used?
String methods in Python
String concatenation
Double quotes vs single quotes
Escape characters
…
Data structures contain pointers
https://www.pythonmorsels.com/data-structures-contain-pointers/
Published: June 13, 2024 21:20
Data structures, like variables, contain references to objects, rather than the objects themselves.
Table of contents
Referencing the same object in multiple places
Data structures store references, not objects
Avoid…