Learn Without Walls
← Back to Python Practice Labs
Lab 1 of 10

Variables & Data Types Review

Back to basics — but faster and deeper

← Lab Home Lab 1 of 10 Lab 2: Conditionals →
⏳ Loading Python... (first load takes ~10 seconds)

📖 Concept Recap

Python has four main data types you’ll use constantly:

Variables are just labels that point to values. Type matters — Python treats "5" and 5 very differently. Use type() to check, and int(), float(), str() to convert.

👀 Worked Example

Study this code carefully before diving into the exercises:

# Data types in action name = "Layla" age = 22 gpa = 3.85 enrolled = True print(type(name)) # <class 'str'> print(type(age)) # <class 'int'> print(type(gpa)) # <class 'float'> print(type(enrolled)) # <class 'bool'> # Type conversion age_as_text = str(age) print("I am " + age_as_text + " years old") print(f"GPA: {gpa:.1f}") # f-string formatting
✏️ Guided

Exercise 1 — Student Profile Variables

Fill in the blanks to create a complete student profile and print a formatted summary. Replace each ___ with a real value.

Output will appear here...
💡 Hint: Strings need quotes. Integers don’t. True and False are capitalized and have no quotes.
💪 Independent

Exercise 2 — Product Inventory

Write code that stores a product name (str), price (float), quantity (int), and whether it’s in stock (bool). Then print:

Output will appear here...
💡 Hint: Use f"Product {name}: ${price} each, {qty} in stock." to format the sentence.
🔥 Challenge

Exercise 3 — Type Conversion Puzzle

Python’s type conversion can fail in surprising ways. Your tasks:

  1. Try to convert the string "3.14" to an integer directly using int("3.14") — run it and see what happens.
  2. Find the correct two-step method to convert "3.14" to an integer.
  3. Print the result and verify its type is <class 'int'>.
Output will appear here...
💡 Hint: You can nest function calls: int(float("3.14")). Think about why that works.
🏆 Mini Project

Mini Project — Personal Profile Card Builder

Build a complete personal profile. Store: full name, age, city, major, GPA, year (Freshman/Sophomore/Junior/Senior), and is_full_time (bool). Then print a formatted profile card that looks like this:

============================ STUDENT PROFILE ============================ Name: Layla Hassan Age: 22 City: Los Angeles Major: Data Science GPA: 3.9 Year: Junior Status: Full-Time ============================
Output will appear here...
💡 Hint: Use f-strings with alignment: f"{'Name:':<8} {name}" creates neat columns. Or just use spaces manually.

✅ Lab 1 Complete!

You’ve reviewed variables, data types, type conversion, and f-string formatting. These are the building blocks of every Python program you’ll ever write.

Continue to Lab 2: Conditionals & Logic →

← Lab Home Lab 1 of 10 Lab 2: Conditionals →