DEV Community

Janet Awino
Janet Awino

Posted on • Edited on

Python 101: Introduction to Modern Python

What is Python?

Python is an interpreted, high-level programming language that was created in 1991 by Guido van Rossum, and is currently being maintained by the Python software foundation. It has a syntax that focuses on code readability thereby allowing beginners to get started easily and programmers to express their concepts in fewer lines of code.

What can Python do?

Python can be used:

  • On a server to create web applications.
  • In big data to perform complex mathematics.
  • For system scripting
  • For software development
  • In machine learning and artificial intelligence

Getting Started with Python

To start programming in Python on your local machine, open a terminal or command prompt and type the following command:

python --version
Enter fullscreen mode Exit fullscreen mode

If Python is not installed on your local machine, download it here.
After installing python, run the above command to make sure Python is correctly installed.
If python is correctly installed you can go ahead and write your python program.

Writing your first Python program

You can either write and run Python code on the command prompt or create a Python file.
To write and run Python code on the command prompt, open the command prompt and type python. You will get output similar to this:

Python 3.10.2 (tags/v3.10.2:a58ebcc, Jan 17 2022, 14:12:15) [MSC v.1929 64 bit (AMD64)] on win32
Type "help", "copyright", "credits" or "license" for more information.
>>>
Enter fullscreen mode Exit fullscreen mode

Here, type print("Hello Python!"). You will get output similar to this:

Hello Python! 
Enter fullscreen mode Exit fullscreen mode

Congratulations!!! You just wrote and run your first Python program on the command prompt.

To create a Python file and run the code, cd into the directory where you want to create the file using the Command Prompt and run the code below:

mkdir python_project && cd python_project 
touch HelloWorld.py
code .
Enter fullscreen mode Exit fullscreen mode

The above instructions will create a folder named python_project and cd into the folder. The second command will create a file named HelloWorld.py. The last command will launch VS Code in our current folder.
If you do not have VS Code installed, you can download it from here.
After launching VS Code, open the HelloWorld.py file and type in the following code:

print("Hello Python!")
Enter fullscreen mode Exit fullscreen mode

Launch the integrated terminal by pressing Ctrl + J. In the terminal, type python HelloWorld.py and hit Enter.
Congratulations on creating and running your first python file.

You can learn more about Python on the official documentation.

Top comments (0)