Python language for beginners

 Python language for beginners




About the Python language

Python is one of the most popular programming languages currently, and all signs indicate that it has been occupying the throne of the most popular programming languages over the past few years. Python has many features that have given it an advantage over other programming languages in many aspects, as it features a dynamic system for interpreting the data type, which means that we will not need to specify the data type for the variables that we know in the code, and the management of memory sources in Python is automated. Python supports many programming styles such as Object-Oriented Programming, functional programming and procedural programming. Python also has the advantage that it has comprehensive Standard libraries that are automatically included in all versions of Python.

The Python language was launched in the early nineties by Guido van Rossum and was so named because of his admiration for a famous theatrical troupe in Britain called Monty Python. Python programming language can be used in the construction and development of small, medium and large programs and applications, and it is recommended to learn it at first for everyone who wants to learn programming in general, because it is easy to learn.




One of the advantages of the Python programming language is that the code in it does a lot with a few lines, you will not need to write many codes and lines of software. The language also helps to write Clean Clean Code, and by this we mean that the code is tidy and easy to read and understand due to the reliance on identification in determining the scope/syntax of the code and not parentheses as in other programming languages. The following table shows some of the differences between Python and Java.

Python has many characteristics and features, we mention some of them in the following list:

An open source programming language.

Programming in it is Object-Oriented OOP.

Easy to learn for beginners.

They can be run on any operating system.

They can be used in many fields such as machine learning, artificial intelligence and image processing 
Networks and information security.

Python is a dynamic language.


Installing Python

There are two main versions of Python, the first is Python 2.x which is the old version of Python and you will receive 
Support is on the security side , and this version will not provide any new features or features. The second version is Version 3.x it is under development, and the latest supported version of this version (at the time of writing this article) is 3.8.1. The following table lists the major python releases and their release dates:

Python 3

VersionRelease date
3.82019-10-14
3.72018-06-27
3.62016-12-23
3.52015-09-13
3.42014-03-17
3.32012-09-29
3.22011-02-20
3.12009-06-26
3.02008-12-03

Python 2


Release date
2.72010-07-03
2.62008-10-02
2.52006-09-19
2.42004-11-30
2.32003-07-29
2.22001-12-21
2.12001-04-15
2.02000-10-16

We will install the latest version of the python version by following the following steps (assuming installation on the Windows system):

Go to the Python language website python.org.

We click on downloads and a menu will appear to us. Click on the python download button as it is in the following image:




After that, the Python installation file with the exe extension will start loading. Save the file where you want and then play it by clicking on it twice.

The following screen will appear to you. Make sure Add python 3.8 to path is selected so that you can run python from the command screen, then click on the Install Now option:





After the installation is finished, the python will be ready for use. The command screen can be opened and the python command can be typed and then Enter and the Python command interpreter will be launched.

To make it easier for you, you can use an editor or a development environment such as Atom, PyCharm, or Visual Code to write and develop code and programs in Python.

Python for beginners - how to write comments in Python

Single-line comments start with the # symbol, comments with more than one line should be enclosed in three quotation marks (single or double) at the beginning and end. See the following example:


# Single line comments start with a number symbol.

""" Multiline strings can be written

    using three "s, and are often used

    as documentation.

"""

Python for beginners-data types and operations

The following examples explain many of the concepts under the heading data types that can be handled in the Python programming language, and how to perform operations on them. The following examples can be implemented in the Python language interpreter directly.

Mathematical operations in Python


1 + 1   # => 2

8 - 1   # => 7

10 * 2  # => 20

35 / 5  # => 7.0

In Python 3, there are two types of division, the first is called " floating point division” and uses the well-known division code / , and the product of the operation is always of the float type:

10.0 / 3  # => 3.3333333333333335
The second type of division is called "floor division” or" integer division” and we use the symbol / / for this type, and the result of the operation is without the comma and the numbers after it:

5 // 3       # => 1

5.0 // 3.0   # => 1.0 # works on floats too

-5 // 3      # => -2

-5.0 // 3.0  # => -2.0

Logical operations (logical operations are case sensitive):

True and False  # => False

False or True   # => True

The logical value False is equal to the number 0, and the logical value True is equal to the number 1:

0 and 2     # => 0

-5 or 0     # => -5

0 == False  # => True

2 == True   # => False

1 == True   # => True

-5 != False != True #=> True

The Equality checking process using ==:

1 == 1  # => True

2 == 1  # => False

Inequality examination:

1 != 1  # => False

2 != 1  # => True

Comparisons:

1 < 10  # => True

1 > 10  # => False

2 <= 2  # => True

2 >= 2  # => True

1 < 2 < 3  # => True

2 < 3 < 2  # => False

The is process checks if two variables refer to the same object or not, but the == process checks if they are the same value or not:

a = [1, 2, 3, 4]

b = a

b is a            # => True

b == a            # => True

b = [1, 2, 3, 4]

b is a            # => False

b == a            # => True
This is where this first part of the python learning journey ends, in which we covered how to install Python, start programming, learn how to write comments and learn mathematical operations . We invite you to participate in the comments and spread the interest.

Comments

Popular Posts