Getting Started
Welcome to Python!
Python is a powerful, beginner-friendly programming language used for everything from web development to data science, automation, and artificial intelligence. It's known for its clean, readable syntax that reads almost like English, making it an excellent choice for your first programming language.
Why Python?
Python is designed to be easy to learn and use. Unlike some languages that require lots of setup and complex syntax, Python lets you focus on solving problems rather than fighting with the language itself. It's also incredibly versatile, so the same language you use to write a simple script can power major applications used by millions of people.
What you'll need
To get started with Python, you need:
- Python installed on your computer (version 3.8 or newer)
- A text editor or code editor (like VS Code, PyCharm, or even a simple text editor)
- A terminal or command prompt to run your programs
Checking if Python is installed
Open your terminal (or command prompt on Windows) and type:
python --version
or
python3 --version
If Python is installed, you'll see something like Python 3.11.5. If you get an error, you'll need to download and install Python first.
Your first Python program
Let's start with the classic "Hello, World!" program. This is a tradition in programming—your first program that prints a message to the screen.
Option 1: Using Python interactively
You can run Python code directly in an interactive session. Open your terminal and type python (or python3):
Use this for quick tests and experimentation. It's great for learning and trying out code snippets.
>>> print("Hello, World!")
Hello, World!
That's it! You just ran your first Python program. The print() function displays whatever you put inside the parentheses.
Option 2: Creating a Python file
For real programs, you'll write code in a file. Create a new file called hello.py and add this line:
Use this for programs you want to save and run multiple times. This is how you'll write most of your Python code.
print("Hello, World!")
Save the file, then run it from your terminal:
python hello.py
or
python3 hello.py
You should see:
Hello, World!
Congratulations! You've written and run your first Python program!
What just happened?
Let's break down what you did:
print()is a built-in Python function that displays text (or other values) on the screen"Hello, World!"is a string, which is a piece of text enclosed in quotes- When you ran the program, Python executed the
print()function and displayed the message
Next steps
Now that you've run your first program, you're ready to learn more! The next lessons will teach you:
- Variables: Storing and using data in your programs
- Types: Understanding different kinds of data (numbers, text, etc.)
- Conditionals: Making decisions in your code
But for now, take a moment to celebrate—you're officially a Python programmer! Try modifying your program to print different messages:
print("Hello, World!")
print("Python is fun!")
print("I'm learning to code!")
Run it again and see all three messages appear. You're on your way!