Site icon Meccanismo Complesso

Python Lessons – 1.1 The Python console

Python lessons - 1.1 The Python console m
Python lessons - 1.1 The Python console
Scrivi una didascalia…

Hello World! Your first program

In this lesson, we will start using the console to write in Python.

As with all programming languages, it is now a good practice to start by writing the writing Hello World!

If you have not already done so, download the latest Python 3.x version from www.python.org, suitable for your operating system. Once installed, you will be able to access the console in several ways:

In both cases, the interpreter will wait for your commands with a prompt consisting of three arrows

Write your first command

then press enter. From the console you will see the text “Hello World” appear directly under the command.

The Python console

The Python console is a program that allows you to enter Python commands one line at a time. This is called REPL (Read-Eval-Print-Loop).

Once you have finished working with the console you can close the Python session by writing the command quit () or exit () and then pressing ENTER.

However, there are commands that will allow you to close both the console and the programs running abruptly.

CTRL + Z to stop the console from running

CTRL + C to stop running a program in Python

The second command will be very useful in cases where a program in Python will loop or it will take too long to wait for the result. With CTRL + C you can abruptly interrupt the program and double check the code to see what caused the loop.

⇐ Go to the Introduction – What is Python

Go to Python Lesson 1.2 – Simple operations ⇒

Exit mobile version