Operator Precedence and Associativity
Precedence decides which operator runs first and associativity decides the direction when two have equal rank. Both are worth knowing, and brackets ar...
A complete core Python path: syntax, data types, operators, strings, control flow, collections, functions, exceptions, files, modules, the standard library, OOP, iterators, generators, decorators, internals, concurrency, regular expressions, testing, typing, performance, security, problem solving, projects, interview preparation and exams.
110 notes in 33 topics
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...
A Python for loop walks over the items of a collection directly. range() supplies numbers when you genuinely need a counter, which is less often than...
while repeats for as long as a condition holds. Use it when the number of repetitions is unknown, and make sure something inside the loop can make the...
break leaves a loop, continue skips to the next iteration, pass does nothing, and the loop else runs only when no break happened.
Printing shapes with loops teaches nested iteration better than any explanation. Every pattern comes from the same three questions.