§ — — Integrative Programming and Technologies 1
In Python, a variable is like a labeled box that stores a value (such as a number or text). You can name these variables to keep track of data. For example, score = 85 stores the number 85 in a variable called score. Python is dynamically typed, meaning you don't declare variable types explicitly; the type (integer, string, etc.) is determined by the value you assign.
Common data types in Python include:
n = 42.price = 17.50.name = "Juan".True or False values, e.g. is_raining = False.Understanding types is important because you can only perform certain operations on certain types. For example, 5 + 3 gives 8, but "5" + "3" (string addition) gives "53" (concatenation).
Operators let us do calculations or comparisons. Key operator types:
+, -, *, /, % (modulo), ** (power). Example: 3 * 4 results in 12.==, !=, <, >, <=, >=. These produce Boolean results. Example: 5 > 3 is True.and, or, not (combine Boolean conditions). Example: True and False is False.An expression is a combination of variables, literals, and operators that evaluates to a value. For instance, total = price * quantity uses the arithmetic * operator. Remember operator precedence (multiplication before addition) when writing expressions, or use parentheses to make your intent clear: (a + b) * c.
ProReviewer — locked
Drills, code labs, and full solutions.
ProReviewer — locked
Drills, code labs, and full solutions.
ProReviewer — locked
Drills, code labs, and full solutions.
Done with this module? Track it — your progress shows on the subject list.
Up next
Lesson 11: Python Refresher — Control Structures and Functions→←Previous: Lesson 9: Python Refresher — Programming and Problem Solving