Lesson 2: Variables and Data Types

Welcome back, inquisitive minds. In this lesson, we shall dissect the very building blocks of Python programs—variables and data types.

What Are Variables?

Variables are akin to empty vessels, ready to hold a multitude of values for us. They are labels, identifiers that we bestow upon data.

x = 5

name = "Blaise"

Data Types in Python

Just as there are many types of vessels—be it a goblet for wine or a cauldron for potions—Python has different data types to hold various forms of data. Here’s a deeper look:

Practice Exercises

  1. Define a variable to hold your age and print it.
      age = 25
  2. Define a variable to hold your name and another for your favorite color. Then print them.
      name = "Blaise"
      color = "blue"
      print(name, color)
  3. Calculate the perimeter of a rectangle using variables for length and width.
      length = 10
      width = 5
      perimeter = 2 * (length + width)

Upcoming Lessons

Leave a Reply