Type Conversion in Python
Python converts numeric types automatically inside an expression and refuses everything else. Explicit conversion is a set of constructor functions, e...
968 published notes across every category.
Python converts numeric types automatically inside an expression and refuses everything else. Explicit conversion is a set of constructor functions, e...
The seven arithmetic operators, the augmented assignment family and the six comparisons, including the chained comparison form that other languages do...
and, or and not return one of their operands rather than a boolean. in tests membership. is tests identity. Each has a use where the others are wrong.
Six operators that work on the individual bits of an integer. Rarely needed in everyday code, routinely needed for flags, masks, permissions and inter...
Precedence decides which operator runs first and associativity decides the direction when two have equal rank. Both are worth knowing, and brackets ar...
Every Python object is either truthy or falsy, the falsy list is short and closed, and knowing it lets conditions read as plain English.
A string is an immutable ordered sequence of characters. Indexing reaches one character, slicing reaches a range, and negative numbers count from the...
Concatenation, repetition, membership testing, comparison and iteration - the operations that work on strings because a string is a sequence.
Case conversion, whitespace trimming, searching, counting and the is-something tests, organised by the job they do rather than alphabetically.
split turns text into a list, join turns a list back into text, and between those two calls sits most of the text processing you will ever write.
Three formatting styles exist. f-strings are the one to use, and the format specification they share controls width, alignment, precision and thousand...
Conditions choose which block runs. Python adds chained comparisons, truthiness and a conditional expression that together remove most of the nesting...