0% found this document useful (0 votes)
33 views

001 Introduction-To-Python-Programming-Langguage

Python is a high-level, general purpose programming language that emphasizes code readability through significant indentation. It is dynamically typed and uses garbage collection, so programmers don't have to manually manage memory or declare variable types. Indentation is syntactically significant in Python, unlike in languages like C and Java, and is used to indicate blocks of code to improve readability.

Uploaded by

sam rehman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
33 views

001 Introduction-To-Python-Programming-Langguage

Python is a high-level, general purpose programming language that emphasizes code readability through significant indentation. It is dynamically typed and uses garbage collection, so programmers don't have to manually manage memory or declare variable types. Indentation is syntactically significant in Python, unlike in languages like C and Java, and is used to indicate blocks of code to improve readability.

Uploaded by

sam rehman
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 17

INTRODUCTION TO

PYTHON
Python Programming Language

Python is a high-level, general purpose programming language, its design emphasises


code readability with the use of significant indentation.

Python is dynamically typed and garbage-collected.


LET'S DECODE
THIS STATEMENT
Python is a high level programming language

High level programming language: A programming language with strong abstraction from
details of computer.

0101101010
a = 10
1010100101
a = 10 + 2
010001010
print(a)
1011010101

Programming Binary/ Machine


CPU
language code
Writing a program using machine code is extremely difficult for programmers.

Hence programmers who write machine code use a more readable format such as
decimal, octal or hexadecimal.

Here is an example of a hexadecimal representation of 32 bit x86 machine code.

8B542408 83FA0077 06B80000 0000C383 FA027706 B8010000 00C353BB


01000000 B9010000 008D0419 83FA0376 078BD989 C14AEBF1 5BC3

The above format, although better than 0's and 1's is still difficult to use.

Hence, assembly language was introduced which provided one abstraction level on top of
machine code.
Assembly Language

To reduce the difficulty of writing machine code, assembly language was introduced.

Assembly language provided one abstraction level on top of machine code.

This is what Assembly code looks like:

More readable than machine code.

Had to directly work with hardware features of the processor


i.e its registers.

Assembly language was still difficult, hence another layer of


abstraction was added on top of it and a more human
readable language like the C programming language was
introduced.
C Programming Language

This is what a C program looked like:

Easy to use and more readable compared to


machine code.

Programmers do not have to deal CPU with


registers directly.

Human readable, uses regular words and


characters.
Levels of programming language

C Assembly Machine

Computer
Human

Mid-level Low-level
programming programming
language languages
Python: High level language
Python is a high-level language because its syntax is more human readable compared to C.
Python is a general purpose language
A programming language used for building software in a wide variety of application
domains.

Python is a GPL because it can be used to write desktop software, create web applications
data science, ML etc.

As opposed to general purpose programming language, we also have domain specific


programming languages(DSL) as well like SQL.

DSL are used within a specific area, i.e sql can only be used for querying relational database
and nothing else.
Python emphasises code readability
Python gives special importance to code readability.

One of the most readable programming languages.

Easy to use, easy to maintain.


Python uses significant indentation
Indentation means having space at the beginning of line of code.

This is what indented v/s non-indented code looks like:

Makes code more readable.

in programming languages like C,C++ and Java indentation is used for code readability and
formatting.

in Python, indentation is the part of syntax.

In Python, indentation is used to indicate a block of code.


Python & Java code blocks comparision

for (int i = 0; i < 5; i++) { for i in range(1, 11):


System.out.println(i); print(i)
}

For loop in Java For loop in Python


Python is dynamically typed
While declaring a variable in C, we need to define the type of variable.

Example: int a = 10.

The type of that variable cannot be changed during execution of code.

Python is a dynamically typed language.

We don't have to declare the type while creating any variable.

Also due to this, a variable can have different type at different times during execution.

In dynamic typing, the type of variable is decided at runtime.


Python is garbage collected
When you write code, you typically need to use data and this data needs to be saved into
memory.

Example, let's say when you create a variable and store a value in it, we are essentially
saving some data at a memory location.

When the program is done using or working with this data, the memory location is still not
freed.

The programmer has to manually free up those spaces/ memory locations which were
previously allocated.

This is another headache for programmers.


Garbage collection
Garbage collection is a process of automatic memory management.

Garbage collector reclaims memory which was allotted by the program but now is no
longer used.

Python is garbage collected, which means as programmers we do not have to worry about
feeing up or reclaiming allotted and unused memory.

We as programmers do not have to manually de-allocate the memory.

You might also like