This post tells what are the basic concepts of programming with Python. In this post we will consider the basic tools reader will need to learn programming. These tools are usually universal for different programming languages, but we will consider them on the example of Python.

Basic idea of programming is to organise the ideas and express them in the way, that machine could understand and perform. In order to create a task for machine performing we must write a program. Programs consist of commands. Generally speaking on the lowest level computer understands binary code – the set of ones and zeros. Different processors can understand different commands (translated into binary code). So to create programmes that can be understood by different types of processors, various programming languages were introduced. Programming languages structure our instructions for computer. Compiler translate a program into the set of zeros and ones.

So, basic tool we will need to start with to write our program is programming software, that can be downloaded by the link for various operating systems. Very powerful action you can do learning a programming language is to read  the language documentation. During this Python course I will refer to official Python documentation or sometimes to some other resources.

Now in order to write code more comfortable and efficiently it is important to use the code editor. There is several code editors are available for download. I prefer to use PyCharm editor. It is very simple for installation and setup.

In order to start program, it is important to start from the basics of the language. Basics we will start with are python identifier and reserved words or keywords.

Python identifiers are created by user names for representing variables, functions, classes and objects. Keywords or reserved words can not be used as an identifiers, as used for developing programming instructions.

Rules for creating identifiers:

  • valid characters – lowercase letters, uppercase letters, digits, underline
  • identifier can not begin with a digit
  •  keyword can be used as an identifier
  • special symbols that can not be used in the identifier name are  !  @  # .  $  %
  • identifier length is 79 characters maximum

Keywords can be false, true, for, else, class and other. In order to return all keywords for python use the code published here in our github repository.

Statements in Python are usually limited with  one line. However continuation symbol \ can be used at the end of the line in order to merge next line. If statements contains in brackets, they do not need continuation symbol.

Quotation symbols in Python are ..., ..., ....

Comments in Python usually marked with hash symbol #.

Next step of learning basics are variables types. The variable assigning to the chosen identifier usually happens with the symbol =. Python standard data types are numbers, strings, lists, tuples and dictionaries.

Numbers in Python can be the types: int, long, float, complex.

Strings in Python are the set of characters in quotation marks – single or double. In order to merge strings, you can use symbol +. Strings can also be sliced with operator [:], starting index is 0.

Lists are another type of data in Python. It can contain both numbers and strings separated with commas and enclosed in square brackets [ ]. The contents and the size of the list can not be changed. List elements numeration starts with 0.

Tuples in Python are data types very similar to lists, but enclosed in parentheses ( ). Tuples can also contain different types of numbers and strings, and contents of tuples and their size can be modified. Tuples numeration starts with 0.

Examples of all data types with comments mentioned in this post are published here in our github repository. 

Educational content can also be reached via Reddit community r/ElectronicsEasy.