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.

8 min Free

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 90 or -3.
  • float: numbers with a decimal point, like 0.05. Floats are approximate.
  • str: text in quotes, like "Masala dosa".
  • bool: True or False.
  • 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.

Variables and typesReady
# 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 ← →.

00/13

Variables

Nothing defined yet.

Output

Nothing printed yet.

What to notice

  1. The right side runs first. In subtotal = price * quantity, Python computes 90 * 2, then attaches the name subtotal to the result.
  2. Types combine by rules. int with int stays int; anything with a float becomes a float. That’s why gst is 9.0.
  3. Comparisons make bools. total >= 150 isn’t a question for you; it’s a value, True, that you can store and test later.
  4. 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.
  5. Conversion is explicit. int(189.0) gives 189. 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.

Check your understanding

1. What is the type of the result of 180 + 9.0?
2. What does int(189.0) return?
3. A function has nothing to report. What does it usually return?