Python Variables
💡
Exercise 6

Data Types 10 XP Easy

Ctrl+Enter Run Ctrl+S Save

Welcome to Chapter 2: Variables! Variables are like labeled boxes 📦 that store information.

💡 Think of it like this: Imagine you have a box labeled "age" and you put the number 10 inside it. That's a variable! You can look at what's in the box anytime, or change what's inside.

name = 'Rex' # A string (text) age = 10 # An integer (whole number) height = 4.5 # A float (decimal number) is_cool = True # A boolean (True or False)

Python has these main data types:

  • 📝 String (str) — Text, always in quotes: 'hello'
  • 🔢 Integer (int) — Whole numbers: 42, -7, 0
  • 🔢 Float (float) — Decimal numbers: 3.14, 99.9
  • Boolean (bool) — Only two values: True or False

You can check what type something is using type():

print(type('hello')) # <class 'str'> print(type(42)) # <class 'int'> print(type(3.14)) # <class 'float'> print(type(True)) # <class 'bool'>
📋 Instructions
Create the following variables: - `name` — set to your name (a string) - `age` — set to your age (an integer) - `gpa` — set to a GPA like `3.5` (a float) - `is_student` — set to `True` (a boolean) Then print each one: ```python print(name) print(age) print(gpa) print(is_student) ```
Remember: strings need quotes, integers don't, floats have a decimal point, and booleans are True or False (capitalized).
⚠️ Try solving it yourself first — you'll learn more!
name = 'Rex'      # A string (text)
age = 10           # An integer (whole number)
height = 4.5       # A float (decimal number)
is_cool = True     # A boolean (True or False)
main.py
Hi! I'm Rex 👋
Output
Ready. Press ▶ Run or Ctrl+Enter.