Python is a high-level programming language. Python implements Object-Oriented concepts. Python can be used to develop software that can be implemented at the commercial level or at the personal level.
Python is equipped with three types of paradigms – structured programming paradigm, Object-Oriented programming paradigm, and functional programming paradigm. Python use well established and well tested and enriched library.
Python is inherited from the ABC programming language, C programming language, Modula-3 programming language, and ICON programming language. Python also supports the development of quick prototypes.
Python is an evolution of ABC programming language and influenced from C, Icon, and Modula -3 programming language. Python was developed to access the calls of the AMOEBA operating System. As AMOEBA operating system is object-oriented, has packages, has use of modules, has classes to provide encapsulation, has a well-defined set of exceptions that are raised while working, the user interface of Python is based on C language, AMOEBA has C modules that are loaded dynamically. To interact with these functionalities Python was developed.
Python is an evolution of the ABC programming language.
ABC Programming Language
ABC is an interactive and user-friendly language. ABC is used as an alternative to the BASIC programming language. ABC is much easier than PASCAL. In ABC structuring of programs can be done. Programs in ABC are comprised of commands, methods, and data sets.
In the ABC language, algorithms are developed, but these algorithms can not address the system-level issues, though ABC can be used to indicate system-level issues.
ABC uses only 5 data types. These 5 data types can be used to represents sets, non-linear data structures such as trees, etc. Since ABC use commands to write programs the length of the programs is shorter than the same program written in Pascal or C programming language.
Programs written in ABC are executable and they are more like ‘pseudo-code.’ ABC can be extended to represent desired programs to do this programmer can define its own set of data structures, internal and external commands, and methods/functions.
ABC follows a top-down approach to do programming. In ABC sorting is bydefault. Pointer in ABC can be sued to implement sorting and searching techniques. In ABC numeric values do not have length and accuracy. In ABC tables are used to store values in a continuous manner.
Commands in ABC are executed as they are written. There is no declaration statement in ABC but it supports Type checking. The ABC has interactive having the facility to get suggestions as the keywords, commands are typed in. To club commands indention is used.
ABC implementation is interpreter due to which developed programs run slower than compiled programs.
Programming Example in ABC
This is a simple program written in the ABC language. Which illustrates how programs are written in the ABC language.
Modula-3 Programming Language
Modula -3 is a programming language influenced by ALGOL, PASCAL, Euclid, Mesa, Oberon, Pascal, and Modula-2.
Modula -3 is a programming language used to implement programming principles such as multithreading, exception handling, garbage collection, and Object-Oriented programming principles.
Modula-3 also has the capability to implement the multiple inheritances and operator overloading features. Modula-3 implemented most of the features that belong to the imperative programming languages.
Modula-3 is not an industrial language but gained its popularity as a teaching language. Modula-3 was taught in Universities. Elego is the only industry in which Modula-3 was used.
In Modula-3 a program is written in the following manner:
Modula-3 programs are written in the module file. The Module-3 program exports the Main module. Modula-3 also supports the import statements. The IMPORT statement can import input-output files.
In Modula-3 all compiled languages are called INTERFACE or MODULE. INTERFACE in modula-3 consists of constants, types, and variables. Exceptions can also be defined in Modula-3. Programs in Modla-3 can be written in procedures. Modula-3 does not support a circular interface.
Modul-3 compiler does not ensure that the program will provide the same result each time it is executed. This language supports the keyword UNSAFE that can be prefixed with the keyword INTERFACE or MODULE. To import the UNSAFE module the interface must also be unsafe.
In Modula-3 programming language generic modules and interfaces can be created. To create a generic module or interface GENERIC keyword is prefixed with the keyword INTERFACE or MODULE.
Modula- 3 supports dynamic allocation. Dynamic allocation allocates data at runtime. Modula-3 grammar supports TRACED and UNTRACED memory. To allocate memory at runtime NEW( ) keyword is used. To free the allocated memory Modula-3 supports DISPOSE method.
Modula-3 implements an Object-Oriented programming paradigm. To create an object of a class OBJECT keyword is used, an object in Modula -3 is of type reference.
Modula-3 also supports exception handling. In Modula-3 exception handling is done in the TRY…EXCEPT block. Modula-3 also supports iterative statements that can be used to repeatedly execute a set of statements until an EXIT occurs. Repeated execution of a particular set of statements is performed using LOOP…EXIT…END programming construct.
Modula-3 supports multi-threading. Multi-Threading is achieved using a runtime library named Thread. A separate thread is used for different tasks for example garbage collection is implemented using a separate thread.
Multiple threads can be implemented using the MUTEX keyword. To control simultaneous access MUTEX is used. The MUTEX can also be locked using the LOCK keyword. MUTEX is considered an object.
Thus Modula-3 is a programming language that has modules, interfaces, constructs to handle safe and unsafe memory allocation, module-3 supports Generics, module-3 has strong types, and has objects that can handle exceptions using Threads.
Components of Python Programming
Python is developed to write programs that are easily readable. Keywords of the Python programming language are written using English alphabet characters. Python does not use curly brackets to define the scope of the block. To define the scope of the Python Indentation is used. To signify the end of the block, the Indentation level is decreased. Thus indentation in Python has predefined meaning.
Python Statements and Control Structures
Python supports assignment statements to assign values of one variable into another variable. Python also supports the if statement which is a decision statement, this statement is used for conditional execution of the set of programming instructions.
To repeatedly execute a set of programming instructions Python uses for statement, while statement in C language this is also known as loops. Statements within the loops are executed till the loop condition becomes false. To stop the execution of the loop break statement is used. To skip execution of a particular set of instructions within the loop continue statement is used.
If an error occurs at runtime that error can be handled using the try…except…finally block. If programming instructions written within the try block raise an error then that error is handled using the except block. The code within the except block gets executed when an error is raised in the try block. Programming instructions within the finally block will always be executed whether an error is raised within the try block or not.
To support the Object-Oriented programming principles Class is used. The class has data member and member functions. The member function may return values. The values can be returned using the return statement.
Python supports del statement this statement deletes the reference from the variable name to its value, if this variable is used again then an error is generated.
Python also supports with statement, this statement contains a code block.
Python also supports pass statement, this statement is used to create code blocks that do not contain any programming instructions.
Python also contains def statement, this statement is used to define and declare different functions.
Python also contains raise statement, raise statement is used to raise and reraise exceptions.
The import statement in Python is used to import different functions or modules with the current program.
Python supports addition, subtraction, and multiplication operators to build expressions. These operators are binary and thus require two operands to be operated upon. The division operator of Python programming language has two types of working first, floor division, second, floating-point division.
Python supports Boolean operators such as and, or and not. Python does not use symbol &&, ||, ! for Boolean operators.
Python also supports Conditional Expression. Conditional expression in Python is written as x if c else y.
Python supports string format operator %. This format operator is used to format string output. Python also supports string concatenation. The “+” operator is used to concatenate strings. This is a binary operator and takes two arguments to work on. These two arguments must be within quotation marks. For example, string “my” and string “street” can be concatenated using the “+” operator like this “my”+” street” results in “mystreet”.
Python supports comparison operator, this operator is used to compare numeric values or values contained with the objects.
Python supports lists and tuples. Lists are declared within square brackets and tuples are declared within parenthesis. The tuples can be concatenated using the + operator. The + operator takes two tuples and combines them to produce a new tuple that contains the value of both the tuples.
Python supports Object-Oriented Programming language and supports class. Class is used to achieve the functionality of encapsulation due to which data member and member functions declared within the class can not be used outside of the class.
Python supports typed objects and variable names are untyped. Operators take specific types of values these values must be compatible with the operator definition. This operator definition is checked at compile time. If the definition of the operator is not satisfied then it will evoke errors and because of this, it is said that Python is a strongly typed language.
Python also supports user-defined types. The user-defined types can be created using classes and these are mostly used in Object-Oriented programming language.
Python supports built-in data types. These built-in data types include bool, bytes, float, int, list, range, set, str, tuple, ellipsis, and frozenset. Bool type accepts a Boolean value, bytes accepts byte sequence, the ellipsis is a placeholder that can be used to declare index, float accepts floating-point numbers, frozenset is used to make sure that set does not contain any duplicate values. str type is used to define character string. A tuple is used to define mixed types.
Python supports Object-Oriented programming paradigm and supports structured programming. Python also supports functional programming. Pythons also support Logic Programming.
Python supports both early binding and late binding. Both early binding and late binding determine the techniques used during Python program execution. This technique determines how the expression will be evaluated.
Python has well-established and tested inbuilt libraries. Python has a vast range library that includes a library for database interaction. Python also has a library that provides functions related to the graphical user interface. If the Python program wants to interact with another computer on the internet or the program wants to pass messages to other computers on the network then to achieve this functionality python supports library that has functions that can be executed to perform functions related to the network communication. Python also supports libraries that support web-based application development.
Python programs are platform-independent that is programs developed in python can be executed on any hardware configuration and any operating system. Python is an Open Source programming language and can be downloaded and used as required.
Python supports a wide variety of character sets. Python supports digits within the range of 0 to 9. Python also supports special symbols, white spaces, and other ASCII and Unicode characters.
Identifiers in Python is the smallest unit which includes punctuation marks and individual words. Python supports keywords, literals, operators, etc.
There are two types of modules first, Predefined Modules and Second, User Defined Modules. All library modules are predefined modules. The library modules are used to do mathematical operations. Those operations that are not defined in predefined modules are carried out by user-defined modules.
All user-defined modules are programmer-defined. User-defined modules can be called from other classes of Python programs.
To import modules import keyword is used. The entire module can be imported or selected objects within a module can be imported.
The syntax of importing a module is:
module_name is the name of the module to be imported.
To import selected objects from a specific module following syntax is used.
module_name is the name of the module from which a specific object is to be imported, object_name is the name of the specific object that needs to be imported.
When the module is imported from the library then the interpreter of python interprets the module code and when the module code is interpreted then it is executed. When the module is interpreted then functions contained with the module are executed. The imported module is used with a new namespace.
Python is a programming language that implements Object-Oriented Programming language. The main influencer of the Python programming language is ABC and Modula-3.