What Are Variables In Python - Python Notes By Mr. BILRED - TechAmbitionX

What Are Variables in Python? | TechAmbitionX

What Are Variables in Python?

Alright, let’s keep it simple.

A variable is just a name that stores some value. Like a box with a label on it.

When you write:

x = 5

You’re saying: “Hey Python, make a box called x, and put the number 5 inside it.”

Some Examples:

name = "Bilal"
age = 21
pi = 3.14

You can use these variables later in your program:

print(name)
print(age + 1)

Variables Can Store:

  • Numbers (int, float)
  • Text (called strings)
  • Boolean values (True or False)
  • Lists, dictionaries, and more

Variable Naming Rules:

In x = 10 "x" is the identifier for the variable storing the value 10. Try not to forget the following rules

  • Don’t start names with a number
  • No spaces allowed (use underscores like user_name)
  • Use meaningful names (atleast when you're showing that to your boss)

Wanna Try?

x = "Mr. BILRED"
print("Welcome,", x)

You’ll see:

Welcome, Mr. BILRED

Yup. That’s your first dynamic print(if you did it first time, obviously).

bGlmZSBtb3ZlcyBwcmV0dHkgZmFzdCwgbWFuLi4uIEdvIGxpdmUgYSBsaXR0bGUh

Understand The Topics:

Comments

Popular posts from this blog

Bits, Bytes, Binary, and ASCII: The Fundamentals of Data Representation - Compiled By Bilal Ahmad Khan AKA Mr. BILRED - TechAmbitionX

C++ escape sequences with clear examples and outputs - Compiled By Bilal Ahmad Khan AKA Mr. BILRED

C++ Prog Lang In A Nutshell VOL #2 Compiled By Bilal Ahmad Khan AKA Mr. BILRED - TechAmbitonX