Tutorial: Learning to think like a programmer with Python
What Will I Learn?
This tutorial covers these topics:
- Basic programming concepts
- What is Python?
- Installation of the work environment
- Operate in the interactive development environment
- A PC/laptop with any Operating system such as Linux, Mac OSX, Windows OS.
Note: This tutorial is performed in Sublime Text 3 in laptop with Windows 7, 32 bit OS, Python 3.6.4.
Anyone without previous programming knowledge or novices can catch up with this tutorial.
In this series of tutorials, we learn the Python programming language from scratch and we will advance to an advanced level. This will be the first part of the tutorial that will cover the topic of programming fundamentals.
Programming is simply giving instructions to the computer to perform a specific task.
The instructions (commands) have a different appearance in each programming language, but there are some basic functions that are presented in almost all languages:
Input: receives data from the keyboard, or from a file or other device.
Output: shows data on the monitors or sends data to a file or other device.
Mathematics: performs basic mathematical operations such as addition, subtraction, multiplication and division.
Conditional operation: confirm the veracity of any condition and execute a sequence of appropriate instructions.
Repeat: perform some action repeatedly, usually with some variation.
When programming, mistakes are made and the process of searching for them and correcting them is called debugging.
There are three types of errors that can occur in a program, syntax, runtime, and semantics.
Python is a programming language created by Guido van Rossum at the beginning of the 90s, it is a powerful scripting language, with dynamic typing, easy to learn, multiplatform and object oriented.
The official Python page is https://www.python.org/
The latest version of Python currently available (March 2018) is Python 3.6.4.
Once the installer is downloaded, we double click on it to start the installation.
- Check the "Add Python to PATH" box to be able to execute programs from the command line. Then, click on "Install now".
- The installation of Python can take several minutes.
- We click on "Close" to finish the installation. You can start programming in Python!
Download Sublime Text
The official page of Sublime Text is https://www.sublimetext.com/
The latest version of Sublime Text currently available (March 2018) is Sublime Text 3.
Install Sublime Text
Once the installer is downloaded, we double-click on it to begin the installation.
- We click on "Next"
- Check the box "Add to explorer context menu"
- We click on "Finish" to finish the installation.
IDLE (Integrated Development Environment for Python) is the development environment that allows you to edit and execute programs. We can also create and execute programs in Python without using IDLE.
Open IDLE Home> Python 3.6> IDLE (Python 3.6)
- The main IDLE window will open. This window shows an informative message about the version of Python we are using and then shows the prompt:
The prompt is the character string >>> that appears on the last line. The prompt indicates that the Python interpreter expects us to enter an order using the keyboard
Our first program
This is an example of the instruction * print *, it is responsible to print a value on the screen. In this case the result is the words * Hello world *.
The quotes mark the beginning and end of the value, they do not appear in the result.
- The print statement can be delimited either by double quotes (") or by single quotes ('):
- Another function of the print instruction is to generate a blank line, writing an order print () without arguments
Posted on Utopian.io - Rewarding Open Source Contributors