No history yet

Introduction to Python

What is Python?

Python is a popular programming language, created in the late 1980s by Guido van Rossum. His goal was to make a language that was easy to read and write, with a syntax that felt almost like plain English. This focus on simplicity and readability has made it a favorite for beginners and experts alike.

It’s an interpreted language, which means you can run your code line by line and see the results immediately. This makes it great for learning and experimenting. Python is also incredibly versatile. Programmers use it for building websites, analyzing data, creating artificial intelligence models, automating tasks, and much more.

Lesson image

Key features of Python include its simple syntax, its status as an interpreted language, and its wide range of applications.

Setting Up Your Workspace

To start coding in Python, you need two things: the Python interpreter itself and a place to write your code. The interpreter is what reads your Python files and carries out their instructions. For writing code, we'll use an Integrated Development Environment, or IDE. An IDE is like a word processor designed specifically for programming, with helpful features like syntax highlighting and error checking.

First, let's install Python. The official source is the Python Software Foundation website at python.org. You should download the latest version of Python 3, as Python 2 is no longer supported. The installation is straightforward, but if you're on Windows, make sure to check the box that says “Add Python to PATH.” This lets you run Python from your computer's command line.

Lesson image

Next, you'll need an IDE. Two excellent, free choices are Visual Studio Code (VS Code) and PyCharm Community Edition. VS Code is a lightweight but powerful code editor with great Python support through an extension. PyCharm is a more specialized IDE built just for Python development. Either one is a fantastic choice.

Download and install your chosen IDE from its official website. Once installed, you might need to install a Python extension (for VS Code) or point the IDE to where you installed Python. Most modern IDEs will detect your Python installation automatically.

Lesson image

Your First Program

It's a tradition in programming to make your first program display the text "Hello, World!" on the screen. Let's do that in Python.

Open your IDE and create a new file. Save it with a .py extension, which is the standard for Python files. For example, you could name it hello.py.

In that file, type the following line of code:

print("Hello, World!")

That's it. The print() function is a built-in Python command that outputs text to the console. The text you want to print goes inside the parentheses, enclosed in quotation marks.

Now, let's run it. Most IDEs have a "Run" button, often a green play symbol, that will execute the code in your open file. You can also run it from your computer's terminal. Just navigate to the directory where you saved your file and type:

python hello.py

If everything is set up correctly, you'll see the output appear in a terminal or output panel within your IDE.

Lesson image

Congratulations, you've just written and run your first Python program.

Quiz Questions 1/5

Who is the creator of the Python programming language?

Quiz Questions 2/5

Python is described as an interpreted language. What does this characteristic mean?