Data Types

STEP 2 β€” Data Types: The Four That Actually Matter

Welcome back, young developer.
In Step 1, your game learned how to remember things. Now it’s time to teach it what kind of things it’s remembering.

Because right now your game is basically asking:
β€œIs 42 a number? A name? A vibe? A cry for help?”

Let’s fix that.

THE BIG FOUR DATA TYPES

These are the four types you will use for most game logic.

  • Integers
  • Floats
  • Strings
  • Booleans

1. Integers β€” Whole Numbers (No Decimals Allowed)

What they are:

Numbers without decimals. Clean. Simple. Whole numbers.

The β€œno drama” numbers.
No decimals. No fractions. No chaos.

Used for:

  • health
  • coins
  • ammo
  • enemy count
health = 100
coins = 25

print(health, coins)
Try yourself.

2. Floats β€” Numbers With Decimals

What they are:

Integers’ dramatic cousins. They show up with decimals like β€œ3.14159 because I’m special.”

Used for:

  • speed
  • accuracy
  • damage multipliers
  • jump height
  • anything that needs precision
speed = 4.5
gravity = 9.8

print(speed, gravity)
Try yourself.

3. Strings β€” Text

What they are:

Anything inside quotes.
Words, sentences, symbols, emojis β€” all strings.

If you can type it like a message to your friend, it’s a string.

Used for:

  • player names
  • item names
  • dialogue
  • dramatic boss warnings
player_name = "Nova"
weapon = "Bow"

print(player_name, weapon)
Try yourself.

4. Booleans β€” True or False

A data type that can only be

True
or
False
.

The β€œyes/no,” β€œon/off,” β€œis it happening or not” data type. No maybes. No situationships.

Used for:

  • is the player alive
  • is the door locked
  • is the boss angry
  • is the game over
is_alive = True
boss_defeated = False

print(is_alive, boss_defeated)
Try yourself.

Code Example: All Four Types in Action

player_name = "Nova"      # string
health = 100              # integer
speed = 3.5               # float
is_alive = True           # boolean

print(player_name, health, speed, is_alive)

Practice (Your Turn!)

Mini Challenge β€” Game Data

Create variables for:

  • player name (string)
  • health (integer)
  • speed (float)
  • is_alive (boolean)
Modify and Run