Writing a Python Program Demo

Writing a Python Program Demo

Lesson Details:
July 10, 2020


I: Introduction

The only way to do good work is to love what you do. And if you don’t love it, get out of it. There is nothing else you can do that will make any difference. — Steve Jobs

Before we go into the details of different programming languages, we need to understand what exactly a computer program is and how it works?

A computer program (also known as software) is a set of instructions that tells a computer system what to do with one or more input data and how to display the output data. Computer programs are written using the source code in the particular programming language and then converted into machine readable executable files(binary files) which can be executed by the computer without human intervention. The most commonly used programming languages today are C, C++, Java, C#, Python etc.

The image shown above is an example of a simple program for sorting numbers. This program takes two numbers as input and then displays the numbers in ascending order. We use various programming constructs such as variables, arrays, loops etc. in such programs. A program is interpreted at runtime by a piece of software called an interpreter.

Example: Interpreted languages include Python and PHP. Compiled languages include C and Java.

The source code in Python and PHP is not compiled directly into machine code. Instead, they must be translated into machine code before they can run on a computer. The process of converting the source code into machine code is known as compilation and this step is performed by a compiler program. Most interpreted languages like Python and PHP require that you compile your program before executing it. Compiled programs run much faster than interpreted programs as they don’t have to be translated every time they run; they only need to be translated once — when originally compiled — and can then be run as many times as required. However, compiled programs may take longer to develop as the programmer has to compile the program each time he or she makes changes and wants to test them. This compilation step can take some time for large programs, so compiling is usually done before testing.

Example: C and C++ are compiled languages. C# and Java are compiled languages too but unlike C and C++, they also provide support for an interactive development environment that allows you to write your program and test it as you write it — without having to compile it first — which speeds up development considerably. These languages are sometimes referred to as “interpreted compiled” languages since they support both compilation and interpretation.

There are many different types of programming languages:

1) Procedural Programming Language: A procedural language uses procedures and functions as the basic unit of modularity. In procedural programming, procedures are focused on performing specific tasks, whereas functions are focused on applying a specific algorithm or logic to a particular input. In procedural languages, after writing a procedure or function, you must define its input parameters as well as its output parameters. In addition, you must specify all the variables it uses and state their data types. Procedures should return a value or values if they need to return a result or results other than their own execution status. If a procedure does not need to return a value upon completion, it should not declare a formal return variable. The output parameters of a procedure or function can be used as arguments in subsequent procedures or functions or assigned to local variables within the same procedure or function body. In procedural languages, procedures and functions can be defined inside other procedures or functions. In procedural programming, all statements must typically execute sequentially from beginning to end unless otherwise specified via program flow control statements such as ‘if’, ‘for’, ‘while’ etc..

2) Object-Oriented Programming Language: An object-oriented programming language uses objects as the basic unit of modularity. In object-oriented programming, objects are self-contained software entities consisting of both data (fields) and functions (methods). Objects can be instantiated (created) from classes (objects templates). Object-oriented languages often support inheritance; this is where an object can inherit behaviour from another object (known as its superclass). Inheritance allows developers to reuse existing code because they only need to implement additional functionality needed for the specific case at hand. Objects can be instantiated (created) from classes (objects templates). Object-oriented languages often support inheritance; this is where an object can inherit behaviour from another object (known as its superclass). Inheritance allows developers to reuse existing code because they only need to implement additional functionality needed for the specific case at hand. It is important to note that OOP was created with the sole intention of making programming easier with fewer lines of code than traditional languages like C/C++/Java etc.. That being said, most developers tend to mix both OOP & procedural approach with most project where procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(interfaces). For example, in most cases we would use procedural approach to model physics behind interactions between objects & OOP approach for defining game logic/behaviour & data representation/interaction between objects & UI elements . Thus more often than not both OOP & Procedural approach are mixed with most projects where Procedural is used at the lower level of interaction between objects & OOP at higher level of abstraction where models are composed of classes/objects which interact via methods & messages(

loader
Course content