INSTACK 360

Variables & Core Data Types

Discover how Python stores data in memory. Master variables and the four fundamental data types: integers, floats, strings, and booleans.

Beginner 5 min read

Variables: Boxes of Data

Think of a variable as a labeled box where you can store data. Unlike older languages, you don't need to declare what type of data the box will hold beforehand. Python is smart enough to figure it out dynamically.

user_name = "Alex"  # Python knows this is text
user_age = 25       # Python knows this is a number

The Four Pillars of Data

Everything you build will rely on these four fundamental types of data:

  • Integer (int): Whole numbers without a decimal point. Perfect for counting. Example: 42, -10
  • Float (float): Numbers with decimal points. Used for precision. Example: 3.14159, -0.01
  • String (str): Text wrapped in single or double quotes. Example: "Hello", 'Python'
  • Boolean (bool): Represents absolute truth. Can only be True or False. Notice the capital letters!

Type Casting: Shape-Shifting Data

Sometimes you need to force a variable to change its type. This is called casting.

price = "50"
# Convert string to integer to do math
actual_price = int(price) + 10  # Results in 60