Introduction to Python MSBTE
PYTHON, to begin with, remember that this programming language is not at all new to computer world, but it wasconceived in the late 1989 by Guido van Russum at Centrum Wiskunde and Informatica (CWI) in the Netherlands.In current computer programming languages, it is very rare to find simple yet powerful programming language that can compete with Python. Currently it is the most used, upgraded and heard programming language among all.
Python is widely used general-purpose, high-level programming language and was mainly developed for emphasis on code readability. All its syntaxes are fuly like real-world English communication sentences and hence allow programmers to express any concept in fewer lines of code.
Before beginning every single discussion about Python, first let's have some interesting facts about Python which makes to stand tall among other languages.
- Python features a simple syntax almost like English language.
- Python has syntax that permits developers to write down programs with fewer lines than another programming languages.
- The Python interpreter runs on the system, which can be executed as soon as the code is written. That means Those patterns can be very fast.
- Python can be treated in a procedural way, object-oriented way, or functional way.
Python is currently most famous programming language, specifically preferred for automation in any kind of industry.
(Currently we have well-known circuits like ARDUINO and Raspberry-PI (R-pi) that allows Python code for developing automation related applications.) Additionally, Python (server-side), software development, mathematics, system scripting, image processing, machine learning, etc. can also be used for web development.
One more important thing Python's too much easy Syntax. As compared to other Programming languages, Python has very easy and readable syntax for any concept.
Python was designed for readability and the English language has some similarities with the effect of mathematics.
Python uses new line (or enter key) to complete/submit/apply any executable command, as opposed to other programming languages which often use semicolons or parentheses.
(Introduction to python msbte)
To define the Python scope, it relies on indentation using whitespace; Such as the scope of loops, functions and classes.
Other programming languages often use curly-brackets ({ }) for this purpose.
Python features:-
The following are some of Python Language features:
1. Interpreted
2. Easy to learn
3. Cross Platform and Portable
4. Platform independent
5. Large Standard Library
6. Object Oriented
7. Auto-destructive (automatic memory management)
8. Free and Open-source
9. Supports exception handling
(Introduction to python msbte)
1. Easy to learn : Python is an expressive and high-level programming language and it was designed for readability.Which means it is easy to understand the language and thus easy to learn.
2. Interpreted : Python is an interpreted language. It performs line-by-line execution of statement with availability of in-time compilers.
3. Platform independent : Python is Platform Independent language. If you have Python code for Windows and if you want to run this code on other platforms like Linux, Unix and Mac, we don't need to make any changes to it, we can run this code on any platform.(Introduction to python msbte)
4. Cross Platform and Portable : Python is available and can run on various operating systems such as Mac, Windows,Linux, Unix etc. Hence it is portable language.
5. Object Oriented : One of the key features of python is, Object-Oriented programming. Python supports object oriented language features like classes and objects, inheritance, polymorphism, encapsulation etc.
6. Large standard library : Python has a large standard library that provides a wide set of modules and functions. So you don't have to write your own code for everything. Many libraries are present in Python for regular expressions, unit-tests, web browsers, etc.6. (Introduction to python msbte)
7. Free and open-source : Python is free to download and use. This means you can download it for free and use it in your application.
8. Auto-destructive (automatic memo management) : Python supports automatic memory management which means the memory is cleared and freed automatically (as the scope of an entity expires). You do not have to bother clearing the memory that we did in C++ by defining destructors.
9. Supports exception handling: An exception is an event that can occur during program exception and can disrupt the normal flow of program.(Introduction to python msbte)
Python's "Everything is Object" Concept OR Python is Dynamic Typed Language
We know that, Python is an object oriented programming language. In Python every single value is an object.For example : If we declare a simple variable,
num = 5
In other programming languages, "num" behaves as variable memory block and "5" is its assigned console value. But here in Python, value "5" behaves as an object and "num" is its reference with automatic data type "integer".
Following others statement : num = 8
In other programming languages "num" is a variable memory block whose new value is now 8 means 5 is over written by new value 8. But in Python value 8 makes a totally new object and reference now refers to new object 8.
In Python, In both cases data type of number is kept as integer now refer following another statement : num = 17.25
Other programming languages will continue the data type of "num" as integer and will perform automatic type conversion.
Other programming languages will store integer version of 17.25 in "num" where as in Python The value 17.25 makes a totally new object and reference "num" now refers to new object 17.25 and will change data type of "num" from integer to float.
It means , python will change data type of any variable /reference according to assigned object /value. Now same will happen when we assign any string value or Boolean value to same reference "num".
Python smart memory management:
(Introduction to python msbte)With respect to above Discussion, let us continue out discussion about Python smart memory management with following statement: N1 = 5 N2 = 5
Other programming languages statements are about to create two different memory blocks N1 and N2 and both will have value 5.
But in case of python (and also in Java) everything is object concept will make fire as a object and both N1 and N2 will behave as reference to same object 5.
Now as we change the value of N2 to 10; other languages value of N2 will get overwrite by new value 10; whereas in Python or new object 10 will be created and N2 will change /move its reference /pointing towards new object 10.
Post a Comment