Python/🐍 Python Foundations/Variables & Data Types

Variables & Data Types

Python is dynamically typed. Variables are created when you assign a value. Common types: int, float, str, bool, list, dict, tuple.

Guided Example

# Example: Variable assignment and type checking
name = "Alice"
age = 30
height = 5.7
is_active = True

print(f"{name} is {age} years old")
print(type(age))  # <class 'int'>

Practice Problems (0/3 solved)

Easy

Swap Two Variables

Given variables a = 5 and b = 10, swap their values and print them.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...

Easy

Type Conversion

Convert the string "42" to an integer, add 8 to it, and print the result.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...

Easy

F-String Formatting

Given name="Data" and score=95, print "Data scored 95 points" using an f-string.

Loading Python...
Loading...

Loading Python runtime (Pyodide)...