Python Programming Language IntroductionPosted by Aezion Inc. Custom Software development on June 26th, 2019 The Python programming language is a popular programming language because of its simplicity, ease of use, open source licensing, accessibility, renowned community, great support and help, tons of packages, tutorials, and sample programs — which make it easy for a beginner to learn and code with Python. Python can be used to develop a wide variety of applications — ranging from Web, Desktop GUI based programs/applications to science and mathematics programs, and Machine learning and other big data computing systems. Let’s explore some key aspects of the Python programming language to get a feel for core features and Python’s user-friendly syntax. Python – A Multi-Paradigm LanguagePython is a multi-paradigm programming language. Meaning it supports different styles of writing code. One can write Python code in a procedural, object-oriented, functional or imperative manner. For this reason, Python is considered a “swiss army knife” in the developer's toolbox. As an “object-oriented” programming language, Python supports all the core features of OOP such as abstraction, encapsulation, polymorphism, inheritance etc. The foundation of OOP is a Class. A class is defined to represent an object that can later be programmatically created and manipulated. The class definition consists of attributes (data) and methods (functions) that collectively define the configuration and behavior of an object. A Python program consists of a collection of classes representing key elements and their behaviors within a system. EncapsulationEncapsulation allows one to hide the internal details or implementation of one object from other objects (s). This protects against accidental or direct access and modifications to the data. Python relies on Encapsulation and other conventions to manage access and usage of class variables or methods. One can restrict access to variables/methods with public, private and protected. A variable or method that is prefixed with double underscore “__“ is treated as private in Python. PolymorphismThe word “Polymorphism” means many forms. Polymorphism is a feature of OOP that allows one to define multiple forms for a common interface. Python’s implementation of polymorphism is similar to other object-oriented programming languages such as C++, Java or C#. Method overloading and overriding are two different ways with which one can achieve polymorphism in the Python programming language. Defining a classA class is defined using a keyword – class. Here’s an example of a student class — consisting of the constructor __init__ — a specific method that gets invoked as part of the object creation. Notice how the methods are defined using the keyword – def. Notice also, that the ‘print_details’ method takes ‘self’ as a parameter and prints the student name, branch and year. InheritanceInheritance is a core object-oriented concept in the Python programming language. It allows one to reuse or extend the functionality or features of one or more classes that are “inherited” in a new class. The concept of inheritance in Python is similar to other high-level programming languages such as C#, Java etc. Let’s define a person class with a method to get the person’s details. Now, let us revise the “Student” class to inherit from “Person” so it can get all the features of the person. Once we inherit from the person, the student gets the behavior “get_details”. Notice, however, that the revised Student class overrides the behavior of “get_details” and adds its own functionality. Note – It’s up to the implementor to decide whether to override a method or not. This article provides an overview of the Python programming language, its core features, and simple, accessible syntax. Hopefully, this brief introduction provides a glimpse into Python’s simplicity and encourages you to explore it as a potential addition to your programmer's toolbox. Aezion Inc. Solution Architects, Engineers, and Developers can assist you in exploring Python-based Software Solutions for your Data Science and Machine Learning applications. Contact us to learn more. Like it? Share it!More by this author |