Posts

Showing posts from December 3, 2020

Python 2.1 - Writing first Python program

Image
Before writing our first Python program, let’s first understand how to install Python software in our computer/laptop. I will not recommend Tablet and mobile for programming. First of all, go to link https://www.python.org/downloads/ and download Python software. Python comes in many versions such as 1.x, 2.x and 3.x where x represents version number. This book uses the latest version 3.8.3 of Python . You can download the latest version. Python 1.x and 3.x have some notable differences. For example, in Python 1.x we used print statement without parentheses and in Python 3.x we use print with parentheses.  In Python 1.x – >>> print “this is a statement” Whereas in Python 3.x –  >>> print(“this is a statement”) You can download Python for Windows, Linux/Unix, Mac or any other operating system. We are using Python for Windows 10(64 bit). Installing Python on windows First of all, check your OS. Then go to the link mentioned above and click on download P

Python 1.6 - Points to remember

  Points to remember ·          Programs are written to get the machine working. ·          A programming language provides an interface to easily write programs. ·          The code written by a programmer in a high level language is called source code. ·          Object code – The code, after compiling C/C++ source code. ·          Byte code – The code, after compiling Python source code. ·          Machine code – The code which is directly executed by a processor. ·          Translator converts the source code into machine code. ·          Compiler executes the entire program in one go whereas Interpreter executes only one statement at a time. ·          Assembler converts the code written in Assembly language.    ·          Python was developed by Guido Van Rossum in the year 1991. ·          PVM (Python virtual machine) – It is a program that translates the Byte code into machine code. Since Interpreter in PVM does the main job, hence PVM is called an Inter

Python 1.2 - Types of language Translators

Image
  Types of language Translators Note : Here we will only talk about general conversion i.e. from source code to direct machine code. We will not talk about the code forms which we will get between source code and machine code. 1.    Compiler Compiler is a program or software which converts the source code written in a high level language into machine code. The compiler reads and executes the entire source code in one go . If there are any errors in the source code (our program) then compiler will report all errors together. So if there are 10 errors in our program then the compiler will report all these 10 errors in one go. Unless we remove all errors, compiler will not execute the code. Once we remove all the errors then compiler will read and execute the entire code again. If the source code is error free then the compiler will successfully execute it and will give the machine code. Languages like C and C++ use compiler. 2.    Interpreter It also converts the source code

Python 1.1 - All about programming world

Image
Before diving directly into python, let’s first understand some concepts about what are programs, why do we write programs, what is a programming language, why do we need it and all the basic concepts about programming world. No matter what programming language you are learning, you must know these things too. These topics can also be asked in job interviews, written exams, viva etc. You are now going to learn a programming language, then as a programmer you must know these basic topics too. So let’s start.  All about programming world We all use popular apps like Google, YouTube, Elyments, Facebook, Instagram, Twitter and millions of other applications. Have you ever thought about how these applications are made? Let me tell you that all these applications are made by writing programs. And to write programs, we need a programming language. So a programming language helps programmers to write programs. Programs can be created for computers, smartphones, tablets and for all the de

Python 1.5 - Flavours/implementations of Python

Image
  Flavours/implementations of Python Flavours of the Python refer to the different types of compilers available. Python offers different types of implementations who work for different purposes. These compilers/flavours are used to integrate various programming languages into Python. A programmer may choose any Python implementation according to his requirements. We have already understood that Python is a “compiled interpreted language” so don’t get confused here. Python code is first compiled to Byte code by a compiler and then Byte code is executed by Interpreter(PVM). Python flavours contain both the compiler and interpreter but we generally say that these are Python compilers. So Python has many compilers, following are some of them –   Python Flavour/Implementation = Python compiler + Python Interpreter 1.    CPython It is the standard compiler for Python that is developed in C language. CPython converts the source code into byte code using C language functions. The ad

Python 1.4 - Strength/Features of Python

  Strength/Features of Python Python has become very popular in the recent past because of its Easy syntax, very easy to learn and understand, readability of code and dynamically typed programming language . Python is giving very tough competition to its competitors such as Java. Following are the features of python – 1.    Readability Python is very simple programming language. When we read a Python program, we feel like reading English sentences. If you are familiar with C or Java, then you would know that these languages use curly braces for block of code but python uses indentation for block of code that makes it very easy to read and understand. 2.    Easy to learn Python has very easy syntax as compared to other languages. Learning Python is extremely easy. If you have good knowledge of C, then Python is equal to the game for you since Python resembles C language. 3.    Dynamically typed This is Python’s most powerful feature. In Python, we need not declare anyth

Python 1.3 - Introduction to Python

Image
  About python Python is a high level general purpose programming language. It was developed by “Guido Van Rossum” in the year 1991 at the Centre for Mathematics and Computer Science, Netherlands. Actually Python’s development started around 1980 but it was initially released for the world in 1991. History - Guido Van Rossum was working on a programming language called “ABC”. It was also a general purpose language with good features. But Van Rossum found that ABC did not have Exception handling, which was a very powerful and mandatory feature. So he decided to develop a new programming language with exception handling. So he started developing python. Python is superset/successor of ABC language . This was not the only reason but there were more. It was one of them. One another reason is that Rossum was working on a project to develop system utilities in ‘C’ programming language where he had to interact with the Bourne shell available in Unix. He felt the necessity of developing a