How to Install TensorFlow on Jupyter Notebook (Anaconda + VS Code)

Install TensorFlow on Jupyter Notebook

If you’ve ever typed import tensorflow as tf inside a Jupyter Notebook and got hit with a ModuleNotFoundError, you’re not alone. This is one of the most common frustrations for beginners getting into machine learning, and it almost always comes down to one thing: TensorFlow was installed in a different environment than the one Jupyter is using. In this … Read more >>

How to Get UTC Time in Python

Get UTC Time in Python

If I need the current UTC in Python, I use datetime.now(timezone.utc) first. It gives me a timezone-aware datetime, which is the safest choice for logs, APIs, databases, and scheduled jobs. What UTC means UTC stands for Coordinated Universal Time. It is the standard time reference I use when I want one consistent clock across servers, apps, and … Read more >>

How to Install Django in Python (Windows, Mac & Linux)

install Django

If you’ve been hearing about Django and want to start building web apps with Python, you’re in the right place. In this guide, I’ll walk you through how to install Django step-by-step — on Windows, Mac, or Linux — from scratch. I’ll also show you how to run your first Django project, install a specific … Read more >>

Get the Current Date and Time in Python (datetime.now)

Current date and time in Python: the Command Prompt showing the DeprecationWarning raised by datetime.utcnow in Python 3.12

datetime.now() is how Python hands you the current date and time, in a single object: For the date on its own, date.today() is shorter. To control how it looks, pass a pattern to strftime(). One thing has changed recently and is worth knowing: datetime.utcnow() is deprecated. The replacement is covered below, along with formatting, timezones … Read more >>

How to Iterate Through Tuples in Python (6 Methods with Examples)

loop through tuple python

Tuples are everywhere in Python: database query results, function return values, coordinate pairs, and configuration settings. And knowing the right way to loop through them can make your code cleaner, faster, and more Pythonic. To iterate through a tuple in Python, you can use a for loop, a while loop, enumerate(), zip(), list comprehension, or itertools.chain(), each suited for a different scenario. … Read more >>

How to Append to a Tuple in Python (5 Methods with Examples)

Append to a Tuple in Python

Every Python developer hits this wall at some point. You have a tuple, you need to add an element to it, and Python throws back a cold AttributeError: ‘tuple’ object has no attribute ‘append’. Frustrating? Absolutely. But it’s fixable, and once you understand why tuples work the way they do, the solution makes complete sense. In this guide, … Read more >>

Python dataclass vs namedtuple: Which Should You Use?

Python dataclass vs namedtuple

If you’ve ever returned structured data from a function or tried to group related values cleanly, you’ve probably run into both namedtuple and dataclass. They look similar on the surface; both let you create objects with named fields, but they’re built for different jobs. I get this question a lot in Python training sessions: “When do I use one … Read more >>