Lesson 1 · Python basics

Variables, f-strings and lists

Check your Python version

import sys
print(f"Python {sys.version.split()[0]}")
Python 3.11.9

Variables and types

name = "Data Analyst"
salary = 65000
is_active = True

print(f"{name} earns ${salary:,} per year")
print(f"Active: {is_active}")
Data Analyst earns $65,000 per year
Active: True

The salary above is an example value used to practise formatting numbers, not market data.

Working with lists

skills = ["Python", "SQL", "Excel", "Tableau"]
print(f"Skills: {', '.join(skills)}")
print(f"Total skills: {len(skills)}")

top_3 = skills[:3]
print(f"Top 3: {top_3}")
Skills: Python, SQL, Excel, Tableau
Total skills: 4
Top 3: ['Python', 'SQL', 'Excel']

Key ideas

  • A variable stores a value under a name.
  • f-strings (f"...") insert values into text and can format numbers ({salary:,}).
  • Lists keep values in order; slicing (skills[:3]) takes part of a list.