The Adventures of Ava the Astronaut: Learning Python One Planet at a Time.
Part 2 Conceptual Complete

Part 2: The Planet of Memory Vaults — Variables and Data Types

The Adventures of Ava the Astronaut: Learning Python One Planet at a Time

Updated March 26, 2025 6 min read

Part 2: The Planet of Memory Vaults — Variables and Data Types

The Adventures of Ava the Astronaut: Learning Python One Planet at a Time


Ava’s New Mission

After sending her first message to the universe, a new planet on Ava’s star map began to pulse with a soft, blue light. The computer screen displayed a new message:

“Welcome to Xylos, the Planet of Memory. To proceed, you must learn to store your mission data.”

Ava realized that to be a real astronaut, she couldn’t just send messages. She needed to remember things: her name, her ship’s fuel level, the number of stars she had counted. But how can a computer remember things? That is what this mission is all about.


The Spaceship’s Lockers: What Are Variables?

Imagine Ava’s spaceship has a huge wall of storage lockers. Each locker can hold one item, and each locker has a unique label on it. If she wants to store her favorite space helmet, she can place it in a locker and label it favorite_helmet. Later, when she needs it, she just looks for the locker with that label.

In Python, a variable is exactly like one of these lockers. It is a named container in the computer’s memory where you can store a piece of information (a value). You give it a name so you can find and use it again later.

Let’s help Ava store her astronaut name, age, and fuel level.

# Storing mission-critical data in our lockers!
astronaut_name = "Ava"
astronaut_age = 12
fuel_level = 99.5
# Now, let's check what's in our lockers.
print(astronaut_name)
print(astronaut_age)
print(fuel_level)

What happens?

When you run this code, the output will be:

Ava
12
99.5

We didn’t have to type “Ava” or 12 directly into the print() function! Instead, we just used the variable name, and Python went to the locker, fetched the value inside, and displayed it. The = sign here is called the assignment operator. It takes the value on the right side and stores it in the variable on the left side. Think of it as “put this value into this locker.”

Important naming rules for variables:

RuleGood ExampleBad Example
Must start with a letter or underscoremy_age, _score1st_place
Can contain letters, numbers, and underscoresplayer_1, high_scoremy-age, my age
Cannot be a Python keywordmy_classclass, print
Case-sensitive (age and Age are different)fuel_Level

The Different Kinds of Space Cargo: Data Types

Ava notices that her lockers can store different kinds of things. She can store a name tag (text), a count of crystals (a whole number), or a precise fuel reading (a number with a decimal). In Python, the values we store in variables also have different data types. Understanding data types is important because it determines what you can do with the data.

Here are the four most common data types you will encounter on your journey:

Data TypePython NameDescriptionExample
StringstrTextual information. Always wrapped in quotes."Hello", 'Python'
IntegerintWhole numbers, with no decimal point.10, -5, 12345
FloatfloatNumbers with a decimal point.3.14, 99.9, -0.5
BooleanboolRepresents truth. Only two possible values.True, False

In our earlier example, astronaut_name holds a string, astronaut_age holds an integer, and fuel_level holds a float. You can always check the type of a variable using the built-in type() function:

print(type(astronaut_name)) # Output: <class 'str'>
print(type(astronaut_age)) # Output: <class 'int'>
print(type(fuel_level)) # Output: <class 'float'>

Talking to Mission Control: The input() Function

Ava gets a message from Mission Control: “Please state your name for the record.” She needs a way to talk back! The input() function lets the program pause and wait for the user to type something in. Whatever the user types is captured and can be stored in a variable.

Let’s build a program that asks for a name and then greets that person.

# Get the user's name from Mission Control
print("Mission Control: Please state your name for the record.")
user_name = input("Enter your name: ")
# Greet the user using an f-string
print(f"Hello, Commander {user_name}! Welcome aboard.")

When you run this, the program will print the first message and then wait, showing the prompt Enter your name: . After you type your name (say, “Alex”) and press Enter, it will store “Alex” in the user_name variable and then print: Hello, Commander Alex! Welcome aboard.

Notice the f before the quotation mark in the last print statement? That creates an f-string (formatted string literal). It is a very convenient way to insert variables directly into a piece of text. You just put the variable name inside curly braces {}, and Python replaces it with the variable’s value. It is much cleaner than trying to glue strings together with + signs!


Space Math: Arithmetic Operators

Ava’s ship computer also needs to do calculations. Python can handle math with ease using arithmetic operators.

OperatorNameExampleResult
+Addition10 + 515
-Subtraction10 - 55
*Multiplication10 * 550
/Division10 / 33.333...
//Floor Division (whole number result)10 // 33
**Exponentiation (power)2 ** 38
%Modulus (remainder)10 % 31

Here is a quick example of Ava calculating her ship’s range:

fuel = 500 # units of fuel
efficiency = 2.5 # light-years per unit of fuel
max_range = fuel * efficiency
print(f"Maximum range: {max_range} light-years")

Output: Maximum range: 1250.0 light-years


Mini-Project: Build a “Space Passport”

Your mission is to create a program that generates a “Space Passport” for any traveler. It should ask the user for their personal details, store them in variables, and then print a beautifully formatted passport.

Your Task:

  1. Use print() to display a welcome message for the passport application.
  2. Use input() to ask for the user’s name and store it in a variable.
  3. Use input() to ask for their age and store it.
  4. Use input() to ask for their home planet (e.g., “Earth”) and store it.
  5. Finally, use print() with f-strings to display all the collected information in a passport-style format.

Example Output:

=== INTERGALACTIC PASSPORT ===
Name : Captain Zara
Age : 14
Home Planet: Earth
Clearance : Approved
==============================

Bonus Challenge: Can you also ask for a “favorite color” and include it in the passport?


Mission Complete!

You have successfully navigated the Planet of Memory! You learned how to use variables to store information, discovered the different data types (strings, integers, floats, and booleans), communicated with Mission Control using the input() function, and even did some space math. The star map is glowing again, revealing a new, mysterious destination.

Next up, we travel to the “Crossroads of the Cosmos,” where we will learn how to make decisions in our code and choose which path to take! See you in Part 3!


This is Part 2 of a 10-part series: “The Adventures of Ava the Astronaut: Learning Python One Planet at a Time.”