Welcome everyone to this series on learning python programming.
This post will be the first in this series and we will see basic introduction to the world of programming before we dive deep into it. This is just to have basics sound and clear. If you are already well versed with it, feel free to skip further to required section. So without any further delay, let’s get started!!!!
What is a Computer program?
- Well, a computer program is nothing but set of instructions grouped together and executed in order to get required result.
- For example, We can write a simple Calculator program code in Python as below for some mathematical operations.
- You can find below code at gitHub.
What is Programming?
- As per technical definition, computer programming is the process of designing and building an executable computer program to accomplish a specific computing result.
- Basically programming involves tasks such as: Information gathering, analyzing, identifying requirements like algorithms, generating algorithms if required in a chosen programming language (commonly referred to as coding).
Why do we need programming?
- Well, Computers are powerful entities, yet they need to be told (input) almost everything like how to perform tasks, evaluate a condition, how to handle data, & how to react if something goes wrong.
- I know you might think, how about AI and ML then? The fact is that AI (based on logic programming paradigm) and ML are also dependent of programs written in some programming language like Python.
Why programming language?
- Logic here is quite simple. We, humans use high level languages (i.e English and others) in our day to day activities.
- Computers use assembly language (i.e. 0’s and 1’s (Binary) to perform its tasks.
- So we use programming language as bridge (interpreter) between our language(High level languages) and computer language(Assembly)
- For list of available programming languages, check this link:
Programming paradigms and languages:
- Programming paradigm, we can put it as an approach towards programming based on operational requirements.
- What I mean by this? well, if you are a NASA scientist, you may deal with kind of mathematics, physics and so on due to space science and calculations, which might be alien concept to a normal person. So you will require an approach that fulfils your requirement.
- Whereas if you are a simple IT programmer, your requirements will be also according to business needs.
- The simple fact is that, there is no single language that has all features in it.
- Programming paradigm helps to classify programming languages based on their features.
- Languages can belong to multiple paradigms. Like Python includes functionalities of Procedural, OOP and functional programming.
- I will not go in much details here about paradigms as it will take sideways as there are number of paradigms that are available. You can read more about them here at
- We will take few examples only as our focus is on Python programming
- Procedural paradigm groups instructions into step by step procedures
- Object-oriented (OOP):
- In OOP, programs are treated as a set of interacting objects.
- Treats computation as the evaluation of mathematical functions and avoids changing-state and mutable data.
- The output value of a function depends on its arguments, so calling a function with the same value for an argument always produces the same result.
- SQL also uses some elements of functional programming.
- Other examples like Perl, PHP, Kotlin do have functional programming support though they are not designed specifically for functional programming.
- Here avg() is called against input numbers 10.0 and 20.0. So avg output is 15. But if you notice, we have not written any code or formula to do this operation because it is already there in the system.
- The desired result is declared as the answer to a question about a system of facts and rules.
- An important concept in logic programming is the separation of programs into their logic component and their control component.
- Example: In this example, simple logic is that, all animal beings die some day and due to this fact, horse named Caesar being an animal will also die some day.
Function is called:
> (avg 10.0 20.0)
Function returns output as:
being = symbol
animal(being) % all animals are beings
horse(being) % all horses are beings
die(being) % all beings die
animal(X) :- horse(X) % all horses are animals
horse(caesar). % caesar is a horse
die(X) :- animal(X) % all animals die
- Procedural languages are third-generation languages (described as first high-level languages) after machine code and assembly language.
- They describe, step by step procedure that should, according to the programmer, be followed to solve a specific problem.
- They use vocabulary related to the problem being solved. For example,
- COmmon Business Oriented Language (COBOL) – uses terms like file, move and copy.
- FORmula TRANslation (FORTRAN) – mathematical language, it was developed mainly for scientific and engineering problems.
- ALGOrithmic Language (ALGOL) – focused on appropriate language to define algorithms, while using mathematical language terminology, targeting scientific and engineering problems, like FORTRAN.
- Programming Language One (PL/I) – a hybrid commercial-scientific general purpose language supporting pointers.
- Beginners All purpose Symbolic Instruction Code (BASIC) – it was developed to enable more people to write programs.
- C – a general-purpose programming language, initially developed by Dennis Ritchie between 1969 and 1973 at AT&T Bell Labs.
- Based on the concept of “Objects”.
- We will talk about “Objects” in detail later in this series.
- This is one of the most widely used paradigm due to its nature.
- Object-oriented programming aims to implement real-world entities in programming.
- Other paradigms are mostly specific to their approach and does not offer flexibility to relate with real world. What I mean by this is that, If you are working for some online shopping company like Amazon, only functional, mathematical or procedural paradigms might not be good choice considering the business structure.
- Many of the most widely used programming languages (such as C++, Java, Python, etc.) are multi-paradigm languages and they do support OOP to a greater or lesser degree.
- The object-oriented paradigm provides key benefits like flexibility, reusability of the code and code extensibility. For more details about OOP, do check Geeks for Geeks