← Courses

Python for AI — Beginner Foundations

Data Science

Basics · Lesson 21 of 76

Variables

A variable is a name you attach to a value so you can use it again later. You create one with =:

Python

A variable can change what it holds at any time — Python doesn't lock it:

Python

Your turn: make a variable city with your town's name, then print "I'm learning Python in <city>".

Check your understanding

Exercise — check your understanding

Create a variable city holding your town's name (any text), then message equal to "I'm learning Python in " joined with city.

You’re reading for free. Sign in to keep your progress and earn a certificate when you finish.Sign in to keep my progress →