8 min · Read · Code · Quiz · Hands-on task included
A variable is a named place in memory where you store a value. Every value has a type—integer, float, string, boolean, and more—which tells Python what operations are allowed and how the data behaves.
Python figures out many types for you, but you still need to think like the interpreter: "Is this a whole number, text, or something else?" When in doubt, print(type(x)) in the REPL.
Bugs often come from misunderstanding types (e.g. concatenating a number to a string without converting). Naming variables clearly and knowing your types makes code easier to read and safer to change when requirements shift.
Create a variable called unit_price set to 4.50, a quantity of 3, and compute total as unit_price * quantity. Print total with a label, and ensure the output is clearly a dollar amount (hint: format or round to two decimal places).