Today I explored one of the most important building blocks in Python ; variables. Variables are like containers that store information we can use later in our program. They make our code dynamic and reusable.
β¨ What I Learned
1. Declaring Variables
You can assign values to variables using the = operator:
first_name = 'Asabeneh'
last_name = 'Yetayeh'
country = 'Finland'
city = 'Helsinki'
age = 250
is_married = True
Here, I stored text (strings), numbers (integers), and even a boolean (True/False).
2. Storing Collections
Variables can also hold lists and dictionaries:
skills = ['HTML', 'CSS', 'JS', 'React', 'Python']
person_info = {
'firstname': 'Asabeneh',
'lastname': 'Yetayeh',
'country': 'Finland',
'city': 'Helsinki'
}
This is powerful because it lets us group related information together.
3. Printing Values
Using print(), I displayed the values stored in variables
print('First name:', first_name)
print('Skills:', skills)
print('Person information:', person_info)
4. Declaring Multiple Variables in One Line
Python makes it easy to declare several variables at once:
first_name, last_name, country, age, is_married = 'Asabeneh', 'Yetayeh', 'Helsinki', 250, True
This is a neat shortcut when you want to initialize multiple values quickly.
π― My Take
Variables are the foundation of Python programming. They let us store, organize, and manipulate data in flexible ways. Whether itβs a single number or a collection of skills, variables make our programs meaningful.
Top comments (0)