Python values and variables
01Store and inspect simple data.
Preparing the interface

WaypointPrepared demo project
Read a complete Waypoint learning loop. Nothing here is saved or sent to AI.
Write small, reusable Python functions that accept inputs, return useful values, and handle a simple edge case.
One topic opens after the required practice has been validated.
Store and inspect simple data.
Turn repeated steps into a clear function.
Choose a result for an edge case.
Collect and transform related values.
Process a list one item at a time.
Model a small record.
Persist a simple result.
Combine the pieces in one useful script.
Current lesson · topic 02
A function gives a repeated step a name. Inputs make it flexible; a return value makes its result available to the next line of your program.
Parameters are names inside the function definition. When you call the function, you provide the real value as an argument. This lets one function work with many values.
print() shows something to a person, while return sends a value back to the code that called the function. A returned value can be stored, compared, or passed into another function.
This function accepts a name and returns a greeting. The caller decides what to do with the returned text.
def greeting(name: str) -> str:
return f"Hello, {name}!"
message = greeting("Maya")
print(message)Why is return more useful than print() when another part of your program needs the value?
Submitted practice · attempt 1
Create a function named total_price that accepts price and quantity. Return price × quantity for a positive quantity. If quantity is zero or less, return 0.
def total_price(price: float, quantity: int) -> float:
if quantity <= 0:
return 0
return price * quantityClear name and both required parameters.
Returns price × quantity for a positive quantity.
Zero and negative quantities return 0.
Readable and direct; a short docstring would improve it.
Evaluation complete
92 / 100
Passed · required practice validated
Topic 03 · Decisions with if statements is now available because this practice passed validation.