Introduction#
Python is one of the most popular programming languages in the world, and for good reason. Its clean syntax and readability make it an excellent choice for beginners, while its powerful libraries make it suitable for everything from web development to data science.
Installing Python#
Before you can start coding, you’ll need to install Python on your computer. Head to python.org and download the latest version for your operating system.
Windows#
- Download the installer from python.org
- Run the installer and check “Add Python to PATH”
- Click “Install Now”
macOS#
macOS comes with Python pre-installed, but it’s often an older version. Use Homebrew to install the latest:
brew install python
Linux#
Most Linux distributions include Python. You can install or update it using your package manager:
sudo apt update
sudo apt install python3
Your First Python Program#
Let’s write the classic “Hello, World!” program. Open your text editor and create a file called hello.py:
print("Hello, World!")
Run it from the terminal:
python hello.py
You should see Hello, World! printed to the screen. Congratulations, you’ve written your first Python program!
Variables and Data Types#
Python makes working with variables straightforward:
# Strings
name = "Alice"
# Numbers
age = 25
height = 1.75
# Booleans
is_student = True
# Lists
favourite_languages = ["Python", "JavaScript", "Go"]
What’s Next?#
Now that you have Python installed and understand the basics, you’re ready to explore more advanced topics like:
- Control flow (if statements, loops)
- Functions
- Object-oriented programming
- Working with files
- Using external libraries
Keep practising, and don’t be afraid to experiment. The best way to learn programming is by writing code!
