An expression is a syntactic form that evaluates to a value or object. Variables, dictionary lookups, function calls, arithmetic, and strings can all serve as expressions. A statement performs an action instead; for example, assert checks a condition rather than producing a value for use elsewhere. section 2.1.3
tasks = ["homework", "laundry", "grocery shopping"]
assert f"First Task: {tasks[0]}" == 'First Task: homework' #1
task_name = "grocery shopping"
assert f"Task Name: {task_name.title()}" == 'Task Name: Grocery Shopping' #2
number = 5
assert f"Square: {number*number}" == 'Square: 25' #3
See expressions evaluated directly inside f-string braces: a list lookup produces homework, a method call produces title-cased text, and multiplication produces 25. section 2.1.3
F-strings can evaluate expressions inside curly braces, which avoids unnecessary intermediate variables. Keep those expressions simple, however. A dense calculation may work but can make the intended output difficult to understand. Prefer named intermediate steps when they improve readability, such as storing scores, their total, the subject count, and the resulting average separately. section 2.1.3
scores = [95, 98, 97, 96, 97, 93]
total_score = sum(scores)
subject_count = len(scores)
average_score = total_score / subject_count
summary_text = f"Your Average Score: {average_score}."
Compare a complicated average calculation embedded in an f-string with the clearer version that separates data, calculation steps, and formatted output. section 2.1.3
A lambda function consists of the lambda keyword, its arguments, and one expression after a colon. That expression supplies the function’s value; a return statement is invalid because return is a statement. For example, doubler = lambda x: x * 2 creates a callable function that produces 10 for doubler(5) and 16 for doubler(8). section 7.1.1
doubler = lambda x: x * 2
Inspect the minimal lambda definition, then compare it with the separate examples showing its function type and calls. section 7.1.1










