Python 3.5 Essentials – 1. Output

When you are trying to learn a new language it is always better if you will see a practical real life result. Let’s try to learn Python from zero and develop a chess game.

The first topic to onboard is Output, because it is the only one way for human to get a result of program execution. For our first programs we will use a text output on screen to console (terminal).

For this series of articles I am using Ubuntu 16.04 where Python 2.7.12 and Python 3.5.2 are preinstalled.  I will write an article to make an instructions for using examples on Windows.

To print some text on the screen we should use print() function in Python. You can create chess0.py text file with following code:

To run this code, open console and type following command:

Now, Python 3.5 will interpret your code and print the chessboard on the screen:

Usually any console is using monospaced fixed-width fonts, so, all characters should be well aligned.  But i=even if we can understand the figures it does not looks like a chessboard. To make it more realistic we can use escape sequences. Now you can modify your code to add right background colors for chessboard cells:

Run python3 again:

chess1

Now, it looks nicer but our code became unreadable. How to make it better with help of variables we will cover in the next article.

Congratulations with your first program on Python 3.5!