Variables, numbers and types
A variable is a name attached to a value, and every value has a type. Run a small restaurant bill line by line and watch Python decide what each value is.
Every program, from a two-line script to an agent framework, does the same basic thing: it gives names to values and works with them. In Python you don’t announce a variable’s type. You write price = 90 and Python looks at the value and decides: that’s an integer.
The types you meet first are:
- int: whole numbers, like
90or-3. - float: numbers with a decimal point, like
0.05. Floats are approximate. - str: text in quotes, like
"Masala dosa". - bool:
TrueorFalse. - None: the special “no value” value.
Press Run to execute bill.py one line at a time. Watch the Variables panel on the right: a new name appears when a line creates it, and a value lights up when it changes.
# A tiny restaurant bill, to see how Python stores values.
item = "Masala dosa"
price = 90
quantity = 2
gst_rate = 0.05
subtotal = price * quantity
gst = subtotal * gst_rate
total = subtotal + gst
paid = total >= 150
note = None
print(item, "x", quantity)
print("Total:", total)
print("Rupees:", int(total))
print("Paid enough?", paid)Press Play to run the program line by line, or step with ← →.
Variables
Nothing defined yet.
Output
Nothing printed yet.
What to notice
- The right side runs first. In
subtotal = price * quantity, Python computes90 * 2, then attaches the namesubtotalto the result. - Types combine by rules. int with int stays int; anything with a float becomes a float. That’s why
gstis9.0. - Comparisons make bools.
total >= 150isn’t a question for you; it’s a value,True, that you can store and test later. - None is not zero and not an empty string. It means “nothing here”. You’ll see it as the return value of functions that don’t return anything.
- Conversion is explicit.
int(189.0)gives189.str(189)gives"189".int("abc")raises an error. Python never guesses a conversion for you.
Why this matters for AI work
When ADK turns a Python function into a tool, it reads the types of the parameters to tell the model what to send. A parameter typed city: str becomes a string field in the tool’s schema. Get the types right and the model gets the schema right.