New in 2026: Master Python for AI, Data Science

ProgrammingPython

Introduction to Python Programming (2026 Edition)

python-programming-670x335

What is Python? (2026 Edition)

Let’s be real — if you’re learning to code in 2026, Python is the obvious first choice. It’s been sitting at the #1 spot on the TIOBE index for several years now, and for good reason. AI engineers use it to train models. Data scientists use it to crunch millions of rows. Web developers ship production apps with it. Automation engineers use it to replace hours of manual work with a five-line script.

Python was created by Guido van Rossum and released in 1991. It’s an interpreted, high-level, general-purpose language with a dynamic type system and automatic memory management. In plain English? You write code that reads almost like English, and Python figures out the rest.

Now compare that to C or Java. In C, before you can even print “Hello World,” you’re dealing with #include headers, int main(), manual memory allocation, and semicolons everywhere. In Python? One line: print("Hello World"). That’s it. This is why Python is the language developers recommend when teaching a friend to code — and that’s exactly what I’m going to do here.

Now you know why Python dominates intro CS courses across Indian colleges — it removes the syntax barrier so you can focus on thinking like a programmer.

Installing Python the Right Way in 2026

The Python ecosystem has grown up. In 2026, the modern way to install Python and manage your projects is with uv — a blazing-fast Python package and project manager written in Rust. It replaces pip, pyenv, and virtualenv in one tool. Here’s how to get started on any OS:

# Step 1: Install uv (works on Mac, Linux, Windows)
curl -LsSf https://astral.sh/uv/install.sh | sh

# Step 2: Install Python 3.13 (current LTS)
uv python install 3.13

# Step 3: Run the Python shell
uv run python

That’s it — three commands and you’re ready to code. uv handles everything: Python version, virtual environments, and third-party packages. No more “it works on my machine” problems.

The Traditional Method (Also Fine)

You can also download Python directly from the official Python website. Download Python 3.13, run the installer, and — this is important — check the box that says “Add Python to PATH” during installation. Without this, your terminal won’t find the python command.

Now you know why developers are moving to uv — one tool, zero configuration headaches.

Choosing Your IDE

An IDE (Integrated Development Environment) is where you’ll actually write your code. There are a lot of options, but here’s my honest take for 2026:

  • VS Code + Pylance extension — My top pick. Free, fast, and has incredible Python support with auto-complete, type checking, and debugging built in. Install the Pylance extension from Microsoft to supercharge it.
  • Cursor — VS Code with AI built directly into the editor. If you want AI code suggestions as you type, this is worth trying.
  • PyCharm Community Edition — A full-featured Python IDE from JetBrains. Heavier than VS Code, but excellent for larger projects.
  • Jupyter Notebooks — The go-to for data science and ML. Write code in cells, see output inline. Perfect for exploring data.

If you’re just starting out, go with VS Code. Install it, add the Pylance extension, and you’re set.

The Python Shell in 2026

One of the best things about Python is that you don’t need to write a full program to try something out. You can use the Python REPL (Read-Eval-Print Loop) — an interactive shell where you type code and see results immediately. Python 3.13 ships with a significantly upgraded REPL: it’s now colorized, supports multi-line editing, and lets you paste entire code blocks.

Launch it using uv:

uv run python

You’ll see something like this:

Python 3.13.1 (main, Jan 10 2026, 10:22:15) on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> 

Now let’s write our first program:

>>> print("Hello World")
Hello World

One line. No boilerplate. No compilation step. That’s the Python promise — and it delivers every time.

Python Overview: The Core Building Blocks

Variables

In Python, variables are containers for data — and you declare them simply as variable_name = value. No int, no String, no type declarations like in Java or C. Python figures out the type on its own.

A few rules to remember: variable names must start with a letter or underscore, can’t start with a number, and can’t be reserved keywords like for or if. Here’s a quick example using f-strings — the modern Python way to build strings with variables:

>>> name = "Ravi"
>>> age = 22
>>> city = "Bengaluru"
>>> print(f"My name is {name}, I'm {age} years old, and I live in {city}.")
My name is Ravi, I'm 22 years old, and I live in Bengaluru.

Notice the f"..." before the string — that’s an f-string (formatted string literal). You put your variable directly inside {} and Python handles the rest. This is the preferred way to build strings in 2026.

Type Hints

Python is dynamically typed, but as of Python 3.5+ you can add optional type hints to your code to make it more readable and catch bugs early. You’ll see this a lot in professional codebases:

def greet(name: str, age: int) -> str:
    return f"Hello {name}, you are {age} years old."

Type hints don’t change how the code runs — they’re a communication tool for you and your IDE. We won’t use them everywhere in this tutorial, but good to know they exist. When you’re ready to go further, our Python Type Hints and Annotations guide covers everything from beginner to pro.

Built-in Data Types

Python has many built-in data types. Let’s walk through them one by one with examples you can try in your REPL right now.

Numbers

Numbers in Python can be integers, floats, Booleans, or complex numbers. Some examples:

  • Integers — 2, 5, 0, -3
  • Float — 1.2, 4.5, 6.0
  • Boolean — True or False (note the capital letters — unlike C where it’s 1 and 0)
  • Complex — 5 + 6j, 4 – 9j
>>> 5 + 8       # Addition
13
>>> 9 - 6       # Subtraction
3
>>> 8 * 9       # Multiplication
72
>>> 8 / 9       # Division (always returns float)
0.8888888888888888
>>> 8 % 2       # Modulus (remainder)
0
>>> 5 ** 2      # Power (unlike C/C++, Python uses ** not ^)
25
>>> num1 = 9
>>> num2 = 4
>>> total = num1 + num2
>>> print(f"{num1} + {num2} = {total}")
9 + 4 = 13

Please note that unlike C/C++, Python uses ** (double asterisk) for the power operator, not ^. Now you know why Python code looks so clean compared to C.

Strings

Strings are sequences of characters. They can be defined with single quotes, double quotes, or triple quotes for multiline strings. In 2026, f-strings are the standard for string formatting — forget %s formatting or .format().

>>> greeting = "hello"
>>> greeting + " world"         # concatenation
'hello world'
>>> greeting[0]                 # indexing (starts at 0, like C)
'h'
>>> greeting.upper()
'HELLO'
>>> greeting.capitalize()
'Hello'
>>> score = 98.5
>>> print(f"You scored {score:.1f}% — great job!")
You scored 98.5% — great job!

Notice the :.1f inside the f-string — that formats the float to one decimal place. F-strings can do a lot. Read more about f-strings in the official Python docs. And if you want to go deeper on everything strings can do, check out our dedicated Python Strings guide.

Lists

Lists are Python’s version of arrays from C or Java — except they’re more flexible. They can hold mixed types and grow dynamically. No need to declare a fixed size upfront.

>>> marks = [85, 92, 78, 95, 88]
>>> marks.append(100)
>>> marks
[85, 92, 78, 95, 88, 100]
>>> marks.sort()
>>> marks
[78, 85, 88, 92, 95, 100]
>>> print(f"Top mark: {marks[-1]}, Average: {sum(marks)/len(marks):.1f}")
Top mark: 100, Average: 89.7

Dictionaries

Dictionaries store data as key-value pairs. Think of them like a hash map in Java or a struct in C — but much easier to use. Perfect for structured data. We have a full deep-dive on Python Dictionaries if you want to explore them further.

>>> student = {"name": "Priya", "age": 21, "branch": "CSE"}
>>> student["name"]
'Priya'
>>> student["cgpa"] = 9.2      # add a new key
>>> print(f"{student['name']} is {student['age']} years old with CGPA {student['cgpa']}")
Priya is 21 years old with CGPA 9.2
>>> student.keys()
dict_keys(['name', 'age', 'branch', 'cgpa'])

Tuples

Tuples are just like lists, except they are immutable — once created, they can’t be changed. Use them when you have data that should never be modified, like GPS coordinates or RGB color values.

>>> location = (28.6139, 77.2090)   # latitude, longitude of Delhi
>>> location[0]
28.6139
>>> rgb_red = (255, 0, 0)
>>> print(f"Red in RGB: {rgb_red}")
Red in RGB: (255, 0, 0)

Sets

Sets are an unordered collection of unique elements — duplicates are automatically removed. They’re incredibly useful when you need to eliminate repetition or do set operations like union and intersection.

>>> languages = {"Python", "Java", "Python", "C++", "Java"}
>>> languages       # duplicates removed automatically
{'C++', 'Java', 'Python'}
>>> languages.add("Rust")
>>> "Python" in languages
True
>>> a = {1, 2, 3, 4}
>>> b = {3, 4, 5, 6}
>>> a & b           # intersection
{3, 4}
>>> a | b           # union
{1, 2, 3, 4, 5, 6}

Now you know why sets exist — whenever you need “unique items only,” reach for a set instead of a list.

User Input with input()

Almost every real program needs to talk to the user. In Python, you use the input() function to read text from the keyboard. Important: input() always returns a string, so if you need a number, convert it.

name = input("What's your name? ")
age = int(input("How old are you? "))   # convert string to int
print(f"Hello {name}! In 10 years, you'll be {age + 10} years old.")
What's your name? Arjun
How old are you? 20
Hello Arjun! In 10 years, you'll be 30 years old.

Loops in Python

For Loop

A for loop is used when you know in advance how many times you want to repeat something. Let’s print the first 5 natural numbers:

>>> for i in range(1, 6):
...     print(f"Number: {i}")
Number: 1
Number: 2
Number: 3
Number: 4
Number: 5

You may be wondering why we wrote range(1, 6) instead of range(1, 5) — that’s because range() goes from the first number up to, but not including, the second number.

While Loop

A while loop keeps running as long as a condition is true — use it when you don’t know the number of iterations in advance.

>>> i = 1
>>> while i <= 5:
...     print(f"Count: {i}")
...     i += 1
Count: 1
Count: 2
Count: 3
Count: 4
Count: 5

The match/case Statement (Python 3.10+)

Python 3.10 introduced match/case — Python’s version of a switch statement (which C and Java have had for decades). It’s cleaner and more powerful. Let’s see it in action:

day = input("Enter a day: ")

match day.lower():
    case "monday" | "tuesday" | "wednesday" | "thursday" | "friday":
        print("It's a weekday — back to work!")
    case "saturday" | "sunday":
        print("It's the weekend — relax!")
    case _:
        print("That doesn't look like a valid day.")

The _ at the end is the default case — it matches anything that didn’t match above. Now you know why Python finally added this — long if/elif/elif/else chains were getting messy.

Errors and Error Handling

Python is very helpful when something goes wrong — it gives you a clear error message pointing to the exact line. Let’s look at the common ones:

>>> int('a')
Traceback (most recent call last):
  File "", line 1, in 
ValueError: invalid literal for int() with base 10: 'a'

>>> sum(1, 2)
Traceback (most recent call last):
  File "", line 1, in 
TypeError: 'int' object is not iterable

You can handle these errors gracefully using a try/except block — so your program doesn’t crash when something unexpected happens:

try:
    age = int(input("Enter your age: "))
    print(f"You are {age} years old.")
except ValueError:
    print("That's not a valid number! Please enter digits only.")
Enter your age: twenty
That's not a valid number! Please enter digits only.

Now you know why error handling is critical — production code must never crash on bad user input. For a complete reference on every exception type and advanced patterns like finally and custom exceptions, read our full Python Exception Handling guide.

Python’s Power: Packages and Modules

Python’s real strength is its enormous ecosystem of packages. The standard library comes built-in — no installation needed. For third-party packages, you use pip install or, if you’re using uv, the even faster uv add.

# Traditional way
pip install requests

# Modern way with uv (faster)
uv add requests

Let’s explore a few built-in libraries:

  • math — mathematical functions from the C standard library
  • datetime — working with dates and times
  • random — pseudo-random number generation
>>> import math
>>> math.sqrt(144)
12.0
>>> math.pi
3.141592653589793

>>> import datetime
>>> now = datetime.datetime.now()
>>> print(f"Today is {now.strftime('%B %d, %Y')}")
Today is March 30, 2026

>>> import random
>>> for _ in range(4):
...     print(f"Random number: {random.randint(1, 100)}")
Random number: 42
Random number: 17
Random number: 83
Random number: 61

Three lines of import and you have access to square roots, today’s date, and random numbers. That’s the Python promise — batteries included.

Python in the Real World

You’ve learned the fundamentals — but where does Python actually get used professionally in 2026? Everywhere.

  • AI & Machine Learning — Libraries like PyTorch, TensorFlow, and scikit-learn power almost every AI model you interact with today, from chatbots to image recognition.
  • Web Development — Frameworks like Django and FastAPI let you build production web apps and REST APIs with Python — Instagram and Spotify were both built on Django. See our comparison of FastAPI vs Flask vs Django when you’re ready to pick one.
  • Automation — With libraries like selenium, playwright, and pyautogui, Python can automate anything that runs in a browser or on your desktop — form filling, report generation, data scraping. Our web scraping with Python and Selenium tutorial is a great hands-on starting point.
  • Data Sciencepandas, NumPy, and matplotlib are the standard toolkit for loading, transforming, and visualizing data at any scale. Check out our roundup of 5 Python libraries that will change how you code for a curated starting list.

Pick any domain that interests you, and Python has a mature library ecosystem waiting for you there.

Practice Makes You Perfect!

Challenge: Fill in the Blanks

Now that you’ve learned the basics, let’s practice. Open VS Code, create a file called practice.py, and fill in the variables so that every print statement outputs True.

###############################################################################
######## Change the variables till all the statements evaluate to True ########
###############################################################################

variable1 =     # a string that starts with "a" and is less than 9 characters
variable2 =     # an integer
variable3 =     # a float greater than variable2
variable4 =     # a list with exactly 5 elements
variable5 =     # a tuple with exactly 2 elements
variable6 =     # a dictionary
variable7 =     # a set with at least 3 unique elements
variable8 =     # any value — use an f-string to print it below

###############################################################################
##################### Don't Change anything Below this ########################
###############################################################################

# test1: Strings
print(type(variable1) == str)
print(len(variable1) < 9)
print(variable1[0] == "a")

# test2: Numbers
print(type(variable2) is int)
print(type(variable3) is float)
print(variable2 = 3)

# test7: f-string
message = f"My variable is: {variable8}"
print(type(message) == str)
print(len(message) > 0)

Run it with uv run python practice.py. If you see all Trues, you’ve got it. If not, read the error, trace it back to the variable, and fix it — that’s debugging, and it’s the most important skill in programming.

You’ve just covered the core of Python in 2026 — from installation to data types to error handling to real-world applications. The language hasn’t gotten more complicated; if anything, the tooling has gotten better. Now the only thing left is to build something. Start small. Pick a problem you care about. Write the code. Break it. Fix it. That’s how every developer you admire learned Python — and now you’re on that same path. Let’s go! 🚀

Related posts
Python

Pydantic Agent Basics: A Complete 2026 Tutorial

ProgrammingPython

Production-Ready MCP Servers — Security, Testing & Deployment

ProgrammingPython

Build Your First MCP Server with Python SDK — Fundamentals

ProgrammingPython

Connect FastAPI to MCP — Two Integration Patterns

1 Comment

Leave a Reply