Learn Python programming language in 15 minutes
14 minute(s) read | Published on: Oct 10, 2021 Updated on: Dec 14, 2021 |
Python object-oriented programming language
This is one of the languages that can be used to program, design, and develop various software and applications—noting that it is an object-oriented language. That is why it is a good option and language for the rapid development of apps.
This language is a fascinating artificial intelligence that learning and programming with it are almost the same. Reading, translating, and even writing code in this is a bit easy, and for this reason, this language is the choice of many developers to develop different types of apps and even websites.
Modules and packages can also be used to program and develop websites and apps ( in French: développer des sites Web et des applications )using this easy and attractive language. This means that because this is using modules, it can be said that it is a modular language. Their modularity means that the code inserted in other artificial intelligence can be easily compiled and executed.
This is popular and attractive, and one of its advantages is that the Library and Standard Interpreter of this language are binary, and its source is also free. There are no restrictions in this machine language, and all users, programmers, and developers can easily use all its tools for design, development, and programming. There are all the necessary tools for growth and innovation in the Main Platforms section without restrictions.
Why is it so popular?
This is one of the most popular and widespread artificial intelligence, the reasons that have made it the most popular language are as follows:
- All tech giants love this, and it has made them flat:
Technology giants do not mean substantial and successful companies in technology. For example, Google, YouTube, Facebook, NASA, Dropbox, Yahoo, Mozilla, Quora, Instagram, Reddit, and even IBM use this artificial intelligence for their designs and developments and consider it an instrumental language.
It should be noted that Google has used this artificial intelligence to implement artificial intelligence and its algorithms.
- This is used in machine learning and development:
The popularity of the Python programming language has increased with the growth and development of data science. Some Machine Learning is listed in this machine language.
- This is suitable for beginners:
This is an excellent choice for people who are new to programming. This is because machine language is straightforward, and people can learn it faster and easier.
- can meet all user needs:
This is a versatile programming language that can meet all users' needs. Skill Up 2018: Developer Skills has prepared a report that concludes it is a scripting language that pen testers or DevOps engineers can use. In this way, all developers and users can create and implement projects that can easily use this programming language. It can be used to design and develop apps, software, and websites to design and develop GUI | Graphical User Interfaces can also be used by developers and designers.
It is good to know that this programming language can also be used for data analysis. This is a multi-purpose artificial intelligence and can completely meet all the user's needs.
Advantages
- Practical
- Modular
- is dynamic
- is object oriented
- Portable
- Can be expanded in C ++ and C + languages
- The level is high
- Have extensive backup libraries
- The feature is integrated
- Developers' productivity is improved by using the artificial intelligence
Disadvantages
It is hard to use other languages because it is an elementary and helpful programming language. Those who use it will hardly use different programming languages because it is easy to work with. After using it, this is more convenient and practical than other machine languages and makes other languages look a little more complicated.
- Weaknesses in app development for mobile devices ( in German: App-Entwicklung für mobile Geräte ) Python is a language that can work better. It has good results in developing different apps, programs, and software for platforms such as desktops and operating systems. That is why this language can be used in designs and developments on platforms such as desktop operating systems and have the best and most desirable results. However, Python has performed poorly on mobile device operating systems and platforms.
Carbon Nelle is a mobile app designed and developed by this programming company.
- Slower speed: It is worth noting that it uses some interpreters instead of the compiler, and using interpreters also reduces the program's rate and its implementation and execution.
- Runtime Errors: Since this artificial intelligence is a dynamically coded language, it also has limitations. Therefore, this language needs more time to test and may have some errors at runtime.
How can we install the Python environment?
The terminal window can be used to know if Python is installed or not on the system, and if even Python is installed on our system, we can still use the terminal window to find out which version of Python is on. It is installed on the system.
So, I open the terminal window and enter Python to check the results it shows us:
If that is not installed on your system, you can go to its official and reputable website http://www.python.org to download it and download the desired version of it there.
How to install it on systems and devices running Unix / Linux:
1- To do this, I refer to the address http://www.python.org/download using your favorite browser.
2- The link I refer to provides us with a code for Unix / Linux resources in zip format.
3- I download the files related to it and then decompress them to use them.
4- Activate the Modules / Setup option to make some custom settings.
5- Then, we must run the script./configure.
6- After that, the Python installation process begins.
7- After performing the above steps and completing the Python installation process, Python will be saved in / usr / local / bin, the default installation and storage path.
How to install it on systems and devices running Windows:
1- To do this, enter the address http://www.python.org/download through the desired browser and refer to it.
2- The inserted link provides the compatibility file for installing it, suitable for the Windows operating system. The version I need to establish is XYZ.
3- Of course, you should note that to install it on your system, Microsoft Installer 2.0 must be installed on your procedure beforehand.
4- After that, you must install the installer file on the machine and run it. It would help if you made sure that the system supports MSI.
5- After that, I will run the downloaded file.
How can we change the installation path on Unix / Linux operating systems after installation?
Note that to install it, the system provides a default path until the file is installed in that path. To be able to change the direction after the installation process, you must follow the steps below to do this easily.
To be able to add this to a Unix session in the desired folder, follow the steps below:
1- In the csh shell section, it is better to enter the phrase setenv PATH "$ PATH: / usr / local / bin / python" and then press the Enter key.
2- In the bash shell (Linux) section, you must enter the phrase export PATH = "$ PATH: / usr / local / bin / python and press Enter.
3- In the sh or ksh shell field, it is better to enter the phrase PATH = "$ PATH: / usr / local / bin / python and press Enter to confirm it.
NOTE:
/ usr / local / bin / python is the path where Python is placed in the system.
How can we change the installation path on Windows operating systems after installation?
To add it to a session in the desired folder and Windows operating system, it is better to follow the following steps:
Enter the path% path%; C: \ Python, and then press Enter to confirm at the command prompt.
environment variable in it
- PYTHONPATH: This variable can have the function that PATH has and act like it. The role of this variable is to inform the Python interpreter where to find the files. This variable must contain the source library directory. Of course, it should be noted that the installer sets PYTHONPATH.
- PYTHONSTARTUP: This variable includes the initialization path. Of course, this file also contains the Python source code. This variable can be set up and executed each time the interpreter launches.
- PYTHONCASEOK: Using the PYTHONCASEOK variable in the Windows operating system, you can command to find the first instance in the import command.
- PYTHONHOME: This variable is also an alternative to the module search path, and this variable can be in the folders PYTHONSTARTUP and PYTHONPATH.
Launch it by using the Interactive Interpreter method
We need to enter the word Python in the command line field to do this.
After that, we can start coding in the mentioned section.
.d command: This command can execute the output correctly. Their output also has a .pyo extension
.S-command: It should be noted that to know the stored path of it, do not use the import site command
.-V command: This command can have long outputs that include trace reports with details about import commands. The
. -X command: By using these commands, you can disable exceptions in the class
.-c cmd command: This command can convert sent scripts to
. cmd.File: can run this language script from a specific file.
command-line Interactive Interpreter
We can run this language script at the command line by calling an interpreter.
Use command-line) (Interactive Interpreter
It is also possible to run it by using the GUI.
- IDLE: Unix is the first IDE to be modified for it.
- PythonWin: Windows is also the first for it.
basic syntax in it
Note that it is almost identical to Perl, C, and Java.
If you call the interpreter without sending a script file as a parameter, you will get a prompt:
Then enter the following commands and then press Enter:
If you are using a newer version of this computer language, be sure to use () along with the Print commands. Like print ("Hello, Python!") ;.
What are the naming rules in it?
There are some rules and restrictions in naming variables that must be observed. The rules are listed below:
1- The class name must start with capital letters.
2- Other identifiers should be entered in lower case.
3- If we define an identifier and use (_) at the beginning of its name, it means that this identifier is private.
4- If we start the ID with two underlines, the ID is powerfully private.
Words reserved in it.
Some words are reserved in it and should not be used as variables or constants.
- Assert
- Break
- Class
- Continue
- Def
- Del
- Elif
- Else
- Except
- Finally
- For
- From
- Global
- If
- Import
- In
- Is
- lambda
- or
- pass
- print
- raise
- return
- try
- while
- with
- yield
It can use{} to specify class definition codes. The following commands can create indentations in the code:
Below we enter the code that will give an error after entering:
The code below is also a correction of the above code that gave an error:
Multiline commands in it
In Python, the code inserted usually ends in a new line, and sometimes we add a character or the \ sign at the end of the lines until it indicates that the continuation of the command is in another line.
Like the following:
Note, however, that the commands inside {}, [], or () do not need to use the \ character again to indicate that the continuation of the code is on another line. Like the following:
Quotation in it
It is possible to use single quotes, pairs of quotes, and even three quotes in Python code. Inside these quotes are string literals.
Comment in it
If we do not enclose the # sign inside the quotation mark, it means that the description can be inserted inside it. After placing the # text, the written texts indicate that those texts are comments, and the interpreter does not check them, and they are not executed.
The output is as follows:
Tuple data type in it
Tuple Items are composed. Of course, this type of data is like a list. Commas separate the values inside this data type. Of course, it should be noted that the values in the list data type are not enclosed in parentheses, but the values in the Tuple are enclosed in parentheses and are enclosed. List data type values are enclosed in [].
The result and output of the code listed above are as follows:
Dictionary data type in it
This type of data in Python is almost like hash tables. The performance of this type of data is almost like the associative array or hashes in Perl.
Items and Dictionary data type values are placed inside... But to use its buys and items and extract them, we have to use []. Like the following:
The result and output of the code listed above are as follows:
List data type in it
The list data type consists of items that commas can separate. Of course, it should be noted that the values of this data type are enclosed in [] and enclosed.
To access the values and items in this data type, you can use ([] [:]) and indices starting from 0 to -1. Like the following:
The result and output of the code listed above are as follows:
Strings in it
Strings are also a set of characters that are enclosed in quotation marks. They can be inserted into a single quotation mark or a pair of quotation marks.
The result and output are as follows: