Introduction to Python Programming
Python Basics
What is Python?
Python is a programming language, a set of instructions we can give to a computer to make it do things. It was created in the late 1980s by Guido van Rossum, who wanted to build a language that was powerful but also easy to read and write. Think of it like a simplified version of other coding languages, with a focus on clarity.
This focus on readability is one of its most famous features. Python code often looks a lot like plain English, which makes it less intimidating for beginners. It's also incredibly versatile. You'll find Python powering everything from websites and mobile apps to artificial intelligence and scientific research. It's the language behind parts of Instagram, Spotify, and Netflix, and it's a favorite tool for data scientists at NASA.
Getting Set Up
To start writing Python, you first need to install it on your computer. The best place to get it is from the official website, python.org. You'll want to download the latest stable version available for your operating system, whether it's Windows, macOS, or Linux.
The installation is straightforward. Once it's done, you'll have access to the Python interpreter, which is the program that runs your code. You'll also get a simple code editor called IDLE (Integrated Development and Learning Environment). It’s a great place to write your first few lines of code.
The Rules of Indentation
One of the first things you'll notice about Python is its use of whitespace. In many other programming languages, curly braces {} are used to group blocks of code together. Python does it differently. It uses indentation, the spaces at the beginning of a line.
This isn't just for making the code look neat; it's a strict rule. Python uses indentation to know which lines of code belong together. For example, in a conditional statement, the code that should run if the condition is true must be indented.
mood = "happy"
if mood == "happy":
print("That's great!") # This line is indented, so it's part of the 'if' block.
print("Keep smiling!") # This line is also part of the block.
print("Have a good day.") # This line is not indented, so it runs after the 'if' block, no matter what.
In Python, indentation is not optional. It's how the interpreter understands the structure of your program. The standard is to use four spaces for each level of indentation.
Your First Conversation
Let's make the computer talk. In Python, the command for displaying text or other information is the print() function. You put whatever you want to show on the screen inside the parentheses.
# This will display the text 'Hello, World!' on the screen.
print("Hello, World!")
Now, what if you want to get information from the user? For that, you use the input() function. It pauses your program, waits for the user to type something and press Enter, and then returns whatever they typed.
We can combine input() and print() to create a simple, interactive program. The code below asks for the user's name and then uses it to say hello.
# Ask the user for their name and store it in a variable called 'name'.
name = input("What is your name? ")
# Greet the user by name.
print("Hello, " + name + "!")
When you run this code, it will first display "What is your name? ". After you type your name and hit Enter, it will print a personalized greeting.
Now that you understand the very basics, let's test your knowledge.
Who is the creator of the Python programming language?
In Python, what is the primary role of indentation?
You've just taken your first steps into the world of Python. You know where the language came from, why it's so popular, and how to write a simple program that can communicate with a user. This foundation is the key to building much more complex and powerful applications.

