Python Basics
Computer Programming and Python fundamentals
Python Introduction
This article offers a brief introduction to Python, highlighting its key features and capabilities. Python is renowned for its simplicity, making it one of the most accessible programming languages. It is intuitive, free, open source, and versatile enough to solve a wide range of everyday problems.
Getting Started with Python
Before diving deeper into Python’s advanced features, let’s begin by installing Python and setting up your development environment.
For this guide, we will use Python 3, the most up-to-date version of the Python programming language. Users with Linux often find Python 3 pre-installed. To check if Python 3 is already installed, open your terminal and run:
$ python3
If Python 3 is correctly installed, you should see a message similar to:
$ python3
Python 3.8.2 (default, Oct 2 2020, 10:45:41)
[Clang 12.0.0 (clang-1200.0.32.27)] on darwin
Type "help", "copyright", "credits" or "license" for more information
>>>
Note
If the above output appears, you're ready to start working with Python. Otherwise, visit the official Python website to download the installer suitable for your operating system.
Writing and Running Your First Python Script
In addition to experimenting within the interactive Python shell, you can also write Python code in a file. Ensure your file has a .py
extension so that Python recognizes it as a script. To execute your script, use the following command in your terminal:
$ python3 myfile.py
Below is an example of a simple Python script:
print("Hello future Python programmer!")
When you run this script using:
$ python3 myfile.py
It should produce the output:
Hello future Python programmer!
We'll predominantly use the Python shell to demonstrate various concepts, but feel free to write and run your own scripts in your favorite code editor as you follow along.
Happy coding!
Watch Video
Watch video content