Posts

Showing posts from March, 2022

Basic of Python Programming

Image
  INTRODUCTION Computer programming languages are designed to process different kinds of data, viz. numbers, characters and strings in the form if digits, alphabets, symbols etc, to get a meaningful output known as result or information. Thus, program written in any programming language consists of a set of instructions are written using specific words and symbols according to syntax rules or the grammar of a language. Hence, every programmer should know the rules, i.e. syntax supported by language for the proper execution of a program. This chapter describes basics of python programming, i.e. syntax, data types, identifiers, tokens, and how to read values fro the user using input function, etc. PYTHON CHARACTER SET Any program written in Python contains words or statements which follow a sequence of characters. When these characters are submitted to the Python interpreter, they are interpreted or uniquely identified in various contexts, such as characters, identifiers, name or con...

SUMMARY & KEY TERMS OF INTRODUCTION OF PYTHON PROGRAMMING 🔥

Image
Summar y A computer is an electronic device accepts data from a user, processes it for calculations specified by the user and generates an output. The hardware of a computer system consists of three main components, viz. input/output (I/O) unit, central processing unit (CPU) and memory unit. A program written in 1s and 0s is called machine language. In assembly languages, machine operations are represented by mnemonic codes such as ADD, MUL, etc. and symbolic names that specify the memory address.  Programs written in high-level languages are similar to instructions written in English language. An Assembler is used to translate an assembly language program into an equivalent machine language program. An interpreter or compiler is used to translate a program written in a high-level language into an equivalent machine code for execution. An interpreter reads the source code line by line and converts it into object code. A compiler is a software which translates an entire program writ...

Python Implementations

Image
  The standard implementation of Python is usually called "CPython" . It is the default and widely used implementation of the Python programming language. It is written in C. Besides C, there are different implementation alternatives of Python, such as Jython, IronPython, Stackless and PypY . All these Python implementations have specific purpose and roles. All of them make use of simple Python language but execute programs in different ways. Different Python implementations are briefly explained ahead. Jython Originally, Jython was known as "JPython". JPython takes Python programming language syntax and enables it to run on the platform. In short, it is used to run Python programs on Java platforms. More details about JPython can be found at http://jPython.org. IronPython IronPython is an open source implementation of Python for the .NET framework. It uses dynamic language runtime (DLR) , which is a framework for writing dynamic languages for .net . A major use o...

Internal Working of Python

Image
 When a programmer tries to run a Python code as a script or instructions in an interactive manner in a Python shell, then Python performs various operations internally. All such internal operation can be broken down into a series. Python   is an object-oriented programming language like Java. Python is called an interpreted language. Python uses code modules that are interchangeable instead of a single long list of instructions that was standard for functional programming languages. The standard implementation of python is called “cpython”. It is the default and widely used implementation of Python.  Python doesn’t convert its code into machine code, something that hardware can understand. It actually converts it into something called byte code. So within python, compilation happens, but it’s just not into a machine language. It is into byte code (.pyc or .pyo) and this byte code can’t be understood by the CPU. So we need an interpreter called the python virtual machine ...

How to Commenting in Python

  Comments in Python are preceded by a hash symbol (#) on a line and called a line comment. Three consecutive single quotation marks''' are used to give multiple comments or comments on several lines at once and called paragraph comment. When the Python interpreter sees #, it ignores all the text after # on the same line. Similarly, when it sees the triple quotation marks ''' it scans for the text ''' and ignores any text in between the triple quotation marks. The following program demonstrates the use of comment statements in Python.

INSTALLING PYTHON ON UBUNTU

Image
  Installing Python on Ubuntu   Ubuntu 20.04 ships with  both Python 3 and Python 2 pre-installed . To make sure that our versions are up-to-date, let's update and upgrade the system with the apt command to work with Ubuntu's Advanced Packaging Tool: sudo apt update. STEP 1:    Open Ubuntu. STEP 2:    Press the Windows button on the keyboard and type ' terminal' or press the shortcut Ctrl+Alt+T to open the terminal.  And then Write the following command for install python. sudo apt-get install python3 STEP 3:   Once the terminal is open, type Python3 --version to check if it is installed. STEP 4:   To launch the command line mode or interactive mode of Python 3.X version in Ubuntu, type Python3 on the terminal. From Figure we can see the command line mode of Ubuntu has been started and programmer is ready to give instructions to Python. The following figure illustrates an example of printing 'hello' in the command line...

Starting Python in Different Execution Modes in Windows

 Starting Python in Different Execution Modes After installing Python in Windows, you can start Python in two different modes, viz. Python (Command Line) and Python (IDLE). Starting Python (Command Line) Python is an interpreted language. You can directly write the code into the Python interpreter or you can write a sequence of instructions into a file and then run the file.     When you execute Python expressions or statements from the command line then you are in interactive mode or interactive prompt. Steps for writing a Python command line in Windows 7 are above are given as follows: STEP 1:   Press the Start button STEP 2:   Click on All programs and then Python 3.9. After clicking on Python 3.9 you will see a list options as shown in figure. STEP 3:    In this list click on Python (Command Line -- 32 bit) . After clicking on it, you will see the Python interactive prompt in Python command line as shown in figure     In fi...

How to install Python in Windows

Image
 installing Python in Windows Python is available all operating systems such as Windows, Mac, Linux/Unix, etc. The complete list of different versions of Python can be found at  http://www.Python.org/downloads  Step-wise details for installing Python in Windows are given below. Step 1: Open an Internet browser (Chrome, Brave, Firefox, Safari). Type  http://www.Python.org / in the address bar and press Enter. Immediately, the following page will appear given figure. Step 2: Click on Downloads and you will see the latest version of Python. Then click All release. Step 3: After clicking on All releases under Downloads browse through the page to the bottom. You will see a list of Python releases as shown in Figure. Step 4: Click on Python latest version and download it. Step 5: Open the folder where you have download the Python latest version pack and double click on it to start installation. Step 6:  After clicking on it you will see the first window to set up Pyth...

History of Python

Image
HISTORY OF PYTHON Python was developed by Guido Van Rossum at National Research Institude for Mathematics and Computer Science in Netherlands in 1990. Rossum wanted the name of his new language to be short, unique and mysterious. Inspired by Monty Python's Flying Circus, a BBC comedy series, he named the language Python.    Python became a popular programming language, widely used in both industry and academia because of its simple, concise and extensive support of libraries. It is a general purpose, interpreted and object-oriented programming language. Python source code is available under General Public License (GPL) and maintained by a core development team at the same institude. Python goals In 1999, Guido van Rossum defined his goals for Python: an  easy and intuitive  language just as  powerful  as those of the major competitors; open source , so anyone can contribute to its development; code that is as understandable as  plain English ; suitable...

Compiler, Interpreter, Linker & Loader in Python

Image
Define Compiler, Interpreter, Linker & Loader in PYTHON Compiler :                         It is a software that translates a program written in a high-level language into machine language. This compiled program is called object code. The object code is an executable code which can run as a standalone code, i.e. it does not need the compiler to be present during execution. Every programming language, such as C, C++ and Java has its own compiler. Interpreter :                       While a compiler converts the whole source code into an equivalent object code or machine code, the interpreter reads the source code line by line and converts it into object code (i.e. a code understandable to the machine. Linker :              It is a program that links different program modules and libraries to form a single executable program. A source c...

Introduction to Computer and Python Programming

Image
Introduction to Computer and Python Programming History of PYTHON 1.1 INTRODUCTION : Nowadays computers have become an integral part of human lives. They are used in diverse sectors to execute a range of everyday tasks such as reservation of tickets, payments of electricity bills, virtual transfer of money, forecasting the weather, diagnosis of disease and so on. In short, each one of us -- directly or indirectly -- makes use of computers. So, before learning python programming language, this chapter explains the basics of computers and different types of programming languages for ease of beginners and then introduces Python in detail, covering installation and execution of Python and Python programs. 1.2 WHAT IS A COMPUTER : The word computer is derived from 'compute' which means 'to calculate'. A computer is an electronic device which accepts data from a user, processes the data for calculations specified by the user and generates and output. A computer performs these...