Skip to main content

Python Tutorial - #1 (Introduction to Python)




  INTRODUCTION TO PYTHON

In this Lecture I am going to teach you about basic introduction of  Python. so let’s start -- All the earlier languages like C, PASCAL, FORTRAN etc. are based on functional aspects of Programming.  i.e. writing program through Functions. But programmers faced a lot of difficulties in functional programming. Then computer scientist thought to develop a new way of programming in which we can do programming by linking with real life examples which can makes programming easier. Thus, they developed a new concept of programming called object oriented programming in which programming were done by using objects and classes. After that JAVA (and other languages also) Java came in the market and it becomes the world most popular language. Java is a pure object oriented programming language. So, if we write any statements, at first we need to define class (due to object orientation) and this become a demerits of Java language. object which do not have any requirement of defining any class also need to define class and this makes program lengthy.
For example—When we write a simple program to add two numbers, we write the program in java as:-

 public class AddTwoNumbers {


   public static void main(String[] args) {
        
      int num1 = 5, num2 = 15, sum;
      sum = num1 + num2;

      System.out.println("Sum of these numbers: "+sum);
   }
}


And the same program in Python like that :-


Here, we can easily finds that Java programming  is lengthy in comparison to Python.
                             Programmers wants a language which contains the features of both (Procedure and object oriented) languages so, they can do Programming as per requirement and there dreams came as true in 1991.




PYTHON

Python was developed by Guido van Rossum in 1991. The name of this language 'Python' was taken from a T.V. show named 'Monty python flying circus '. Actually, Python were created at the beginning of 1990 but it was publically announced in 20 February 1991.

 Today, Python is one of the most popular language of the World. This is because of his some excellent features :--

i)   Simple/Easy to learn = Python is very simple language. By reading his syntax and code we feel like we are reading English alphabets. We can learn its syntax and code very easily.

ii) Open source = Python is free software and can be download from its official website (WWW. Python.org). It also provide their source code and anyone can modifies and can do changes in there source code to use themselves according to there need.

iii) High Level Language = Languages are of two types:-
     a)  Low Level Language  -- In this language programming were done through machine codes (0 and 1). Assembly language and Machine language are two Low level Languages.

    b) High Level Language  -- In this language programming were done through English alphabets. some examples of high level languages are C,Python, COBOL etc.

iv) Platform Independent = Programs (applications) that created from Python language can be executed or can be use in any O.S. like LINUX, UNIX, Windows,Macintosh, etc.

v) Portable = When a program yields the same result on any computer in the world then it is called Portable. Programs developed from Python are Portable.

vi) Procedure and Object Oriented = In Python we can do Object Oriented Programming as well as Procedural (functional) Oriented Programming. 


What is Object Oriented Programming  ??

That programming in which we use the concept of objects and classes are called Object Oriented Programming. Now let's move towards objects and classes. All the things in the universe which are physically exist are called object. Let's take an example, There is a boy named Shyam. So, Shyam exist physically in our house, thus Shyam is an object. Now, Shyam have some properties like their height, weight, color etc. these properties are called attributes and it is represented by variables in Python. Shyam can do various actions like laughing, weeping, talking etc. these actions are represented by methods in Python. So, an objects have their own attributes and methods.
                                                                                                            Now, we are going to explain about classes. Classes are the things which do not exist physically come back to example we saw . There is a boy named Shyam. Here, Boy don't exist physically. so, Boy is a class. we can take another example for more clarity. Suppose a dog named Snoopy will be a object  and dog is class we can also say snoopy is a object of dog class. remember that class also have there own attributes and methods.



Execution of Python Program :-

The code which we write in Python are called Source Code. When we compile a source code then Python compiler convert it into Byte Code. Byte code represents a fixed set of instruction that represent all the operations. size of byte code is just 1 byte (8 bits), after that PVM(Python Virtual Machine) interpreter convert the byte code into machine code (0 and 1). Then the processor (C.P.U.) process the machine code and give their output.

Note:- Extension of Python Source code is .py.
            Extension of Python Compiled file is .pyc.

Language Translator:-
  
A language translator is a software which translates the programs from high-level language to low-level language.

➠There are Two types of Translator:-

a) Compiler = That translator which converts the whole program into other form of language in one go.

b) Interperature = That translator which converts the program line by line into other form of language.

Frozen Binaries :-

The way through which we can provide an applications to the end user are called Frozen Binaries.

➠There are two way to provide the applications that were made from Python to the end user.:-

➢By providing them byte code and they will install P.V.M and can use the application by interpreting the byte code. Second method is to provide them .pyc file , P.V.M and required libraries of python. so, they can use all these to make single (.exe) file and can start to use it in Just a click But .exe file are greater in size in comparison of .pyc file(Byte code).
                                 ##**---------------------**##


Comments

Popular posts from this blog

Python tutorial - #5 (Operators in Python)

Membership Operators This operator helps us to check an element is found in a sequence or not. It gives there result in Boolean value (True or False). ➥There are two types of Membership operator :- a) in b) not in ➢in membership operator This membership operator returns True if an element is found in a sequence and it returns  False When an element is not found in a sequence. Program - #1 ➢not in membership operator This membership operator returns True if an element is not found in a sequence and it returns False if an element is found in a sequence. Program = #2 Identity Operators This operator helps us to check whether two element are same or not. Actually, this operator compares the memory location of two object, if the memory locations are same then objects are also same otherwise the objects are not same.                                      ...

C tutorial for complete beginners(intro to C language)

     A ny programming language has four important aspects viz * The way it stores data * The way it operates upon this data * The way it accomplishes input and output * The way lets u control the sequence of execution of program.  What is C?  C was developed by Ritchie in 1972 at AT and T's Bell laboratories, USA. Interestingly no one pushed it and there was no advertisement made but still programmers of the time preferred it over the older ones like FORTRAN. It was popular due to its simplicity, reliability and it's ease.  Inventor of C language,   Dennis Ritchie Why Still C in 2019?  As per today's opinion that C has been superseded by C++, C# and java one must still start his programming journey with C due to following reasons: 1. C++and C# use object oriented programming and basic programming skills         of C.  2. Mobile devices are today's rage and device like watches, ...

C tutorial #lecture 3

Here you will be introduced to the comments in C and some basic arithmetic operations on variables and you will learn various shorthand operators. Let's get started- Comments in C : Comments in C/C++ and in any other programming languages serve the purpose of improvement of readability of the code.  Comments are enclosed within /*-----------*/. This  symbol is used for multiline comments. For single line comments we use  // symbol  ( two backslashes) The rules of programming language aren't applicable within comments. The text doesn't appear in the output of the code but it appears in the source code. It just makes the program readable for the coder. This is a C code to illustrate comments.  Add caption       Output.  Nesting of comments : Comments written with /*----/*---*/--------*/  can't be nested and are invalid but a comment with  /*------//------*/ can be nested.  The f...