def hello():
print("Hello, World!")
 
hello()
|

Intro to Python

The world's most popular beginner language. Clean syntax, endless possibilities.

1

The Story of Python

In 1991, a Dutch programmer named Guido van Rossum released a new programming language. He named it after his favorite comedy show: Monty Python's Flying Circus. His goal was simple: make programming readable, fun, and accessible to everyone.

0.9
1991

Python 0.9

Guido van Rossum releases the first version from the Netherlands. It already has classes, functions, and exception handling.

2.0
2000

Python 2.0

List comprehensions and garbage collection arrive. The community grows rapidly as Python becomes a serious tool.

3.0
2008

Python 3.0

A major redesign focused on consistency and removing old patterns. The version everyone uses today.

#1
Today

#1 Language

The most popular programming language in the world, used by Google, NASA, Instagram, Spotify, and millions of developers.

Fun Fact
The name "Python" has nothing to do with snakes. Guido van Rossum was reading scripts from "Monty Python's Flying Circus" while developing the language and wanted something short, unique, and slightly mysterious.

Python is now the #1 language for beginners and the top choice for data science, AI, and machine learning. It is taught in more universities than any other language and has one of the largest developer communities in the world.

2

Hello, World!

Every programmer's journey starts with the same ritual: making the computer say "Hello, World!" In Python, it takes just one line.

Your first Python program
print("Hello, World!")

print() is a built-in function that displays text on the screen. You pass it a value inside the parentheses, and Python outputs it. That is the entire program. No setup, no boilerplate, no semicolons.

Compare that to other languages:

Language Hello, World!
Python print("Hello, World!")
Java System.out.println("Hello, World!");
C++ std::cout << "Hello, World!" << std::endl;
Rust println!("Hello, World!");

Now let's try variables and f-strings (formatted strings):

Variables and f-strings
name = "Alex" age = 14 print(f"My name is {name} and I am {age} years old")
Output
My name is Alex and I am 14 years old

In Python, you create a variable just by giving it a name and a value. No let, var, or int keyword needed. The f-string (notice the f before the quote) lets you embed variables directly inside a string using curly braces {}.

Try it in the Python REPL (Read-Eval-Print Loop). The >>> prompt means Python is waiting for your input:

Python REPL session
>>> 2 + 2 4 >>> "hello" * 3 'hellohellohello' >>> len("Python") 6 >>> type(42) <class 'int'>
Fun Fact
You can multiply a string by a number in Python. "ha" * 3 gives you "hahaha". Python is full of small surprises like this that make it feel playful and intuitive.
3

Lists and Loops

Python's lists store collections of items, and for loops let you do something with each one. The syntax is so clean it almost reads like English.

Creating a list
fruits = ["apple", "banana", "cherry"] print(fruits[0]) # apple (indexing starts at 0) print(len(fruits)) # 3
Looping through a list
for fruit in fruits: print(f"I like {fruit}")
Output
I like apple I like banana I like cherry

Indentation matters in Python. The indented line under the for statement is the loop body. Python uses indentation (usually 4 spaces) instead of curly braces {} to define code blocks. This forces clean, readable code.

You can also use range() to loop a specific number of times:

Looping with range()
for i in range(5): print(f"Count: {i}")
Output
Count: 0 Count: 1 Count: 2 Count: 3 Count: 4

Python also has list comprehensions, a powerful shorthand for building lists:

List comprehension
squares = [x * x for x in range(6)] print(squares) # [0, 1, 4, 9, 16, 25]
Fun Fact
The for x in collection pattern is one of Python's most loved features. Unlike C-style loops (for (int i = 0; i < n; i++)), Python's version says exactly what it means: "for each item in this collection, do something."
4

Functions

Functions let you wrap up a block of code, give it a name, and reuse it. In Python, you define a function with the def keyword.

Defining a function
def greet(name): return f"Hello, {name}! Welcome to Python."
Calling the function
message = greet("Alex") print(message)
Output
Hello, Alex! Welcome to Python.

def defines a function. name is a parameter, a placeholder for the value you pass in when you call the function. return sends a value back to wherever the function was called from.

Functions can take multiple parameters and have default values:

Default parameters
def power(base, exponent=2): return base ** exponent print(power(3)) # 9 (3 squared) print(power(2, 10)) # 1024 (2 to the 10th)

Here is a more practical example, a function that processes a list:

A function that filters a list
def find_long_words(words, min_length=5): result = [] for word in words: if len(word) >= min_length: result.append(word) return result animals = ["cat", "elephant", "dog", "giraffe"] print(find_long_words(animals))
Output
['elephant', 'giraffe']
Fun Fact
Python functions are "first-class objects," meaning you can pass them around like variables, store them in lists, or return them from other functions. This makes Python incredibly flexible for advanced patterns.
5

What Makes Python Special

Python is not the fastest language or the most compact. What makes it special is a combination of readability, versatility, and an enormous ecosystem of tools and libraries.

Abc

Readable Syntax

Often called "executable pseudocode." Python reads almost like English, making it easy to learn and easy to maintain.

pip

Massive Ecosystem

Over 400,000 packages on PyPI (the Python Package Index). Install anything with pip install.

AI

AI and Data Science

The #1 language for machine learning, data analysis, and AI research. Libraries like NumPy, Pandas, and TensorFlow power it all.

www

Web Development

Frameworks like Django and Flask power major websites including Instagram, Pinterest, and Dropbox.

>_

Automation

Automate file management, web scraping, emails, spreadsheets, and more. Python is the Swiss Army knife of scripting.

dev

Huge Community

Millions of developers, thousands of tutorials, and a welcoming community that helps beginners get started.

Dynamic typing means you do not declare variable types. Python figures them out automatically. Write x = 42 and Python knows it is an integer. Write x = "hello" and now it is a string. This makes prototyping fast, though large projects sometimes add type hints for clarity.

Here are some of the most popular Python libraries and what they do:

Pandas

Data analysis

NumPy

Math and arrays

TensorFlow

Machine learning

Matplotlib

Charts and plots

Django

Web framework

Beautiful Soup

Web scraping

Pygame

Game development

Pillow

Image processing

Fun Fact
Python's philosophy is captured in "The Zen of Python," a set of 19 guiding principles. You can read them by typing import this in the Python REPL. The most famous line: "There should be one, and preferably only one, obvious way to do it."
6

Try It Yourself

Ready to write some Python? Here is a quick reference to get you started. Open the terminal and follow along.

Getting Started

1 Install Python: apt install python3
2 Create a file: nano hello.py
3 Write your code and save (Ctrl+X, Y, Enter)
4 Run it: python3 hello.py

The REPL

1 Start the REPL: python3
2 Type any expression and press Enter
3 Try 2 + 2 or print("hi")
4 Exit with exit() or Ctrl+D

Here is a mini-project to try. Create a file called quiz.py and paste this in:

Mini-Project: Quick Quiz Game

This program asks the user a question and checks their answer.

# quiz.py - A simple quiz game def ask_question(question, answer): guess = input(question + " ") if guess.lower() == answer.lower(): print("Correct!") return 1 else: print(f"Nope! The answer was {answer}") return 0 score = 0 score += ask_question("What planet is closest to the sun?", "mercury") score += ask_question("What language is this written in?", "python") score += ask_question("How many legs does a spider have?", "8") print(f"You got {score}/3 correct!")

Run it with python3 quiz.py and answer the questions. Then try adding your own questions to the quiz.

Challenge
Modify the quiz to keep track of a high score, or add a timer using Python's time module. Can you make it pick random questions from a bigger list? (Hint: import random and use random.sample().)

Pythonista!

You've explored the language that powers AI, web apps, data science, automation, and so much more. Python's readable syntax and massive ecosystem make it the perfect first language.

0
Sections Explored
0
Time Exploring

Readable by Design

Python uses indentation and clean syntax so code reads almost like English.

Batteries Included

Python ships with a huge standard library, and pip gives you access to 400,000+ packages.

Versatile and Powerful

From web apps to machine learning to automation, Python handles it all.

Beginner Friendly

Python is the #1 language taught in universities and the top choice for first-time programmers.

Ready to Create?

Put your new knowledge into practice!

Suggest a Correction