Posts

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...