Variables in Python

A variable in Python is a name that refers to a value stored in memory. It’s used to store data that your program can manipulate.

Python is dynamically typed. so you don't have to declare the type

Rules for Python Variables

  1. 1. Must start with a letter or an underscore
  2. 2. Can contain letters, numbers, and underscores
  3. 3. Case-sensitive (name and Name are different)
  4. 4. No special characters or spaces

✅ Valid Example ✅

_name = "Robert"

❌ Invalid Example ❌

1age = 27

Printing Variables

Printing variables means displaying their values using the print() function.

For Example:

age = 27
print(age)

If you want a better understanding of Variables in Python Click the link below to watch a video about Variables in Python

https://youtu.be/qclBTldc8nE?si=PPZA5VHvBSDHEX0i Next

Challenge (optional)

Make a program that has a variable called "age" and give it the value of your age and then finally print the variable

r


⏳ Loading...