Machine Language (Low Level Language)

Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 20

Overview

Machine Language (low level language)

- Low-Level language is the only language which can be understood by the computer.
- It is also known as Machine Language.
- The machine language contains only two symbols 1 & 0.
- All the instructions of machine language are written in the form of binary numbers 1's & 0’s.
Assembly Language (middle level language)

- It is a computer language in which the instructions are created using symbols such as letters, digits and special
characters. 
- Assembly language is an example of middle-level language.
- In assembly language, we use predefined words called mnemonics.
- Binary code instructions in low-level language are replaced with mnemonics and operands in middle-level
language. But the computer cannot understand mnemonics, so we use a translator called Assembler to translate
mnemonics into machine language.
- Assembler is a translator which takes assembly code as input and produces machine code as output.
- Assembler is used to translate middle-level language into low-level language.
High Level Language

- It is a computer language which can be understood by the users.


- It is very similar to human languages and has a set of grammar rules that are used to make instructions more easily.
- It is easier to understand for the users but the computer can not understand it.
- It needs to be converted into the low-level language to make it understandable by the computer.
- Compiler or interpreter are used to convert high-level language to low-level language.
- Languages like FORTRAN,C, C++, JAVA, Python, etc., are examples of high-level languages.
Compiler, Interpreter, and Assembler are types of language processors that convert programming -
.languages to machine language (binary code)
.Compilers and interpreter are used to convert High-Level Language into machine language - 
Assemblers are used to convert Low-level Language or Assembly Language Code into Machine -
Language (Binary code
:Differences between interpreter and compiler

Interpreter Compiler

Scans the entire program and translates it as a whole into machine


Translates program one statement at a time. code.

Compilers usually take a large amount of time to analyze the


Interpreters usually take less amount of time to analyze the source code.
However, the overall execution time is comparatively slower than compilers. source code. However, the overall execution time is comparatively
faster than interpreters.

Generates Object Code which further requires linking, hence


No Object Code is generated, hence are memory efficient. requires more memory.

Programming languages like JavaScript, Python, Ruby use interpreters. Programming languages like C, C++, Java use compilers.
Python Overview
 
 
?What is Python
 
Python is an interpreter, high-level, general-purpose programming language. It is simple and easy to learn with high level of -
.readability
.To program using Python, interpreter is needed -
.You might also need to download some of the third-party libraries that fit your need -

PYTHONSTARTUP File

It is an environment variable you will define specifying the location of the path to a python file. This python script will be run by python
before starting the python interactive mode (interpreter). You can use it for various enhancements like preloading modules, setting
.colors
 
Comparing a small program in c++ with the same program in Python:
 
:++C
>include <iostream#
)( Int main
{
For (int i=0; i<5;i++)
{
;Std::count<<"The value of I is: "<<I<<std::endl
}
;return 0
}
 
:Python
 
:For i in range (0,5)
Print("The value of i is: ", i)
Python is much clearer than C++. It doesn't contain any semicolon or curly parentheses and the -
.syntax is much easier and high readable
 

Python is slower than java and, for sure, slower than C/C++ (this is because of huge libraries and -
modules in Python). But this is not an issue because of the increasing of the power processing of
.modern computers
 
Python is an open source with almost free third-party library. There is a huge list of third-party -
modules that could be installed into Python to extend its usage. For example, scipy and numpy made
.Python suitable for scientific work in a way similar to matlab for free
 
There are many open sources and commercial IDEs that could be used with dozens of features to code -
.and execute Python
Python 3 vs Python 2
 
Python 2
'print 'Hello world>>>
 
Python 3
print ('Hello world')>>>
 
.Python was released in 1991 with the idea of readability -
.In Oct 2000, Python 2 was released -
In Dec 2008, Python 3 was released with a major upgrade that contains many new features mainly in streaming which is not compatible -
.with Python 2
.many mistakes that exists in Python 2 was avoided in Python 3 -
.For these reasons Python 3 is not compatible with Python 2
 
There are some third-party modules that still works under Python 2 only. So, there is an utility called 2to3 program was developed to -
.transform Python 2 codes into Python 3
Python Features:

.Because of Python readability and easy to use, Python became the fastest growing language -
.Python is packaged with so many libraries, both standard and third party-
.High level of readability and clearance-
.Reduces the time of maintenance and speed up programs writing-
.Open source-
.According to Stack-overflow site, it grew rapidly-
.Python learning curve is short-
.Its code is small compared to other languages which leads to high productivity-
.It makes us focus on their programming problems-not the code its-
:Python implementations
 
:CPython
It is the main Python implementation -
- .It is written in C

:Jython**
.Jython is a java implementation of Python-
.it compiles Python code into Java byte code-
 
:Iron Python
.Uses .NET inside Python-
.It is supported by Microsoft-
.It works similar to Java-
 
:Pypy
.It is Python written in Python-
.The interpreter itself is written in Python-
:Python Installation
Access web site: www.Python .org, then click download. You can-
.download Python for Windows, Apple mac and Linux

:Integrated Development Environment(IDE)

:There are three main IDEs for Python


 
:Text editor-1
.Open any editor and start coding, then add '.py' suffix to the file name -
.double click the file or use command line to execute the code -
 
Some editors don't have any feature that speed up the coding process such as coloring, autocomplete, executing code, error -
.check ...etc. like notepad
 
.Others like vim, emac and sublim support the above features -

:Web-based environment-2
.The only one available is jupyter notebook
.It supports interactive development which means that you enter the code on a cell and receive an immediate result
 
:Full IDE-3
.It supports almost all necessary features needed to get coding done quickly -
.A well known types are pycharm and spyder -
:Pycharm IDE
:Running Python code

.From command line you can issue the command Python, then write the codes of Python -
- From jupyter or pycharm you can press Run button.
:Interpreter as a calculator

.Interpreter can be used as a calculator -


It can run (add, sub, multiply divide and so on) -
 
"%" Modulo operator-
.Return the remainder of division
 
"//" Floor division
Return an integer resulting for division (for example: 15//2=7)
 
-:Power operator "**" or Pow(x,y)
.Return the exponential value for a number
:Help on the run

.Python dir () function returns all available objects including the modules that you import-
 
.builtins_ object contain all functions available for use_
 
.To learn about any object, you can use help function-
:For example
help(round)
.takes which is required attribute and ndigits as optional
 
.You can run help on the functions you create-

You might also like