When I started my #100DaysOfCode journey, I began with frontend development using React, then moved into backend development with Node.js and Express. After that, I explored databases to understand how data is stored and managed, followed by building full-stack applications with Next.js. It is now time to start learning Python, not from scratch, but as a refresher to strengthen my fundamentals and expand my backend skillset.
Learning Python strengthens my core programming skills and offers a new perspective beyond JavaScript. It aligns with backend development, data handling, and automation, allowing me to build on my existing knowledge and become a more versatile developer.
Today, for Day 61, I focused on revisiting the core building blocks of Python.
Core Syntax
Variables & Data Types
Variables are used to store data, and Python automatically assigns the data type based on the value.
name = "Ali" # string
age = 22 # integer
price = 99.99 # float
is_active = True # boolean
You don’t need to declare types explicitly like in some other languages; Python handles it dynamically.
Conditionals (if/elif/else)
Conditionals let your program make decisions.
age = 20
if age >= 18:
print("Adult")
elif age > 12:
print("Teen")
else:
print("Child")
This is fundamental for controlling program flow, especially in backend logic (auth checks, validations, etc.).
Loops (for, while)
Loops allow you to repeat actions.
for i in range(3):
print(i)
count = 0
while count < 3:
print(count)
count += 1
for is used more often in Python, especially when working with collections.
Functions
Functions group logic into reusable blocks.
def add(a, b):
return a + b
print(add(2, 3))
They help keep your code clean and modular.
Data Structures
Lists
Lists store multiple items in order.
numbers = [1, 2, 3, 4]
print(numbers[0]) # 1
Dictionaries
Dictionaries store data in key-value pairs, similar to objects in JavaScript.
user = {
"name": "Ali",
"age": 22
}
print(user["name"])
Must Know:
Looping through dicts
for key, value in user.items():
print(key, value)
Nested data handling
data = {
"user": {
"name": "Ali"
}
}
print(data["user"]["name"])
👉 This directly maps to:
- JSON (backend APIs)
- Database data
Sets
Sets store unique values.
nums = {1, 2, 2, 3}
print(nums) # {1, 2, 3}
Tuples
Tuples are like lists, but immutable (cannot be changed).
point = (10, 20)
Loops & Iteration
Looping through collections:
numbers = [1, 2, 3]
for num in numbers:
print(num)
Using range():
for i in range(5):
print(i)
Nested loops (useful for complex data):
matrix = [[1, 2], [3, 4]]
for row in matrix:
for item in row:
print(item)
Functions
Functions are where your code becomes structured and reusable:
Functions make your code reusable and structured.
def greet(name="User"):
return f"Hello, {name}"
print(greet())
print(greet("Ali"))
👉 Think:
“How do I structure logic cleanly?”
Good function design = cleaner code + easier debugging + better scalability.
Working with JSON (IMPORTANT FOR BACKEND)
import json
data = json.loads(json_string)
json_string = json.dumps(data)
JSON is how data is exchanged between frontend and backend.
Example:
import json
json_string = '{"name": "Ali"}'
data = json.loads(json_string)
print(data["name"])
👉 This is directly used in:
- APIs
- Django / Flask
Basic File Handling
Working with files is a fundamental skill in backend:
- Reading files
- Writing files
with open("file.txt", "r") as f:
data = f.read()
👉 Useful for:
- Logs
- Data processing
- Simple storage tasks
List Comprehension (VERY USEFUL)
squares = [x*x for x in range(10)]
A shorter and cleaner way to write loops.
Equivalent version:
squares = []
for x in range(10):
squares.append(x*x)
👉 Cleaner + faster code
Final Thoughts
Today wasn’t about learning something completely new; it was about reinforcing the fundamentals. Python feels simple on the surface, but mastering these basics is what makes you effective when building real-world applications.
Thanks for reading. Feel free to share your thoughts!
Top comments (0)