No history yet

Introduction to Python

Welcome to Python

Python is a programming language known for its simplicity and readability. Think of it less like a cryptic code and more like a set of clear instructions you can write in something close to English. This design makes it one of the best languages for beginners to learn.

Lesson image

But don't let its simplicity fool you. Python is incredibly powerful. It's used by companies like Google, Netflix, and NASA for everything from web development and data analysis to artificial intelligence and scientific computing. Whether you want to build a website, analyze data, or automate repetitive tasks, Python is a fantastic tool to have in your belt.

Getting Set Up

Before you can start writing code, you need to install Python on your computer. The process is straightforward and works on Windows, macOS, and Linux.

First, head to the official Python website at python.org and download the latest version. The website usually detects your operating system and suggests the correct installer.

Lesson image

Run the installer and follow the on-screen instructions. On Windows, it's very important to check the box that says "Add Python to PATH." This allows you to run Python from your computer's command line, which is a useful skill to have.

Along with the language itself, the installation includes a simple program called IDLE (Integrated Development and Learning Environment). An IDE is basically a text editor with special features for writing code, like syntax highlighting and debugging tools. IDLE is perfect for beginners, but many developers use more advanced IDEs like Visual Studio Code or PyCharm.

Your First Program

It's a tradition in programming to make your first program display the text "Hello, World!" on the screen. It's a simple way to confirm that everything is set up correctly.

Open IDLE (you can find it by searching your computer's applications). You'll see a window with a >>> prompt. This is the Python shell, where you can type commands one at a time. Type the following and press Enter:

print("Hello, World!")

You should see Hello, World! printed on the next line. That's it! You've just written and executed your first line of Python code.

The print() command is a built-in function in Python. Whatever you put inside the parentheses (and quotes, if it's text) will be displayed on the screen.

While the shell is great for testing small snippets, you'll usually write longer programs in script files. In IDLE, go to File > New File. This opens a new window, which is a plain text editor. Type the same line of code in this new window.

Now, save the file. Go to File > Save and name it something like hello.py. The .py extension is important, as it tells the computer this is a Python file. To run it, go to Run > Run Module (or just press F5). The output will appear back in the original shell window.

Quiz Questions 1/5

Which of the following best describes Python as a programming language?

Quiz Questions 2/5

When installing Python on Windows, what is the crucial step mentioned in the text that allows you to run Python from the command line?

Congratulations! You've set up your environment and run your first program. You're officially on your way to becoming a Python programmer.