Python uses DYNAMIC typi ng AND A COMBIN ATION of referen ce counting AND A cycle-detecting GARBAGE collec tor for
memory MANAGEMENT. It A LSO FEATURES DYN AMIC NAME RESOLUTION (LATE bindi ng) which binds methods AND VARI ABLE NAMES
during PROGRAM execution .
As we know, whenever we run ANY APPLICA TION it gets LOA DED into RAM AND some memory get s ALLOCATED by O S for THAT
APPLICATION. Fig-1 shows the SAME. Now, Fig-2 shows the different AREA C REATED in the AL LOCATED memory f or
running the APPLICATION.
Code AREA :- Fi xed in size AND code gets LOADED in this AREA.
STACK ARE A:- It MAY grow or s hrink DYNAMICALL Y AND is respons ible for the ord er in which meth od will be
resolved. Also in this L OCAL VARIABLE r eference ARE CREATED .
HEAP AREA :- This A LSO MAY grow or shrink DYNAMICAL LY AND is respo nsible to store A NY object in Pyt hon. Here
object get stored in RAN DOM order. Every object which ge ts stored here w ill HAVE A speci fic ID. GARBAGE collector
runs in HEAP AREA from time to time AND destroys the obj ect which ARE no t HAVING ANY re ference.
VAR IABLE AREA :- In This section VARIABLES ARE s tored AND they r efer their corres ponding object i n HEAP AREA.
Anaconda Installation:-
What is ProgrammingLanguage and Operating System and why do we need them?
A brief introduction to computer memory
Types of ProgrammingLanguages
Sl No Low Level Programming Language High Level ProgrammingLanguage
1 More closer towards system, less closer towards user More closer towards user, less closer towards system
2 Need to know the underlying architecture of machine on
which you are coding
No need to know the underlying architecture of machine
on which you are coding
3 Bit complex t o lea rn an d writ e the c ode, no t
man age able whe n p rog ra m g rows an d n ot i deal to
develop large application
Easy to lear n an d write the c ode, easily m anage able
when prog ram gr ows and ideal to develo p large
application
4 As a programmer you need to manage the memory and
handle the security issues in your program
Compiler or VM is responsible to manage the memory
and handle the security issues your program
5 Code is not portable. Code is portable.
6 Not expressive Expressive
7 e.g. Machine code, Assembly code e.g. C, C++, Java, Python etc
8 Sample code Sample code
What is Source code, Byte code and Machine code inPython?
Type of Errors inPython:-
Compiled Languages vs Interpreted Languages
Why do we need translator?
Why do we need Byte code?
Why Python is compiled and interpreted both? Can’t we make it either compiled or interpreted?
What is Python?
What are some good features of Python?
Memory Management in Python:-
Garbage Collection inPython
Different Flavours of Python
There ARE different FLAV OURS or IMPLEME NTATION of pytho n ARE AVAILABLE . Out of which t he most common ARE: -
1. Cpy tho n: - C IMPLEMENTATION of Python, devel oped to ru n C APPLICATION on PVM, wh ich WAS desi gned using C.
2. Jyt hon :- JAVA IMPLEMENTATION of Python , dev elope d to run JAVA APPLICATION on PVM, w hich WAS de signe d
using JAVA.
3. PyP I:- P yth on IMPLEMENTATION of Python. Impl ement s JIT comp iler, to i mprov e the PERFORMANCE of python
APPLICATION.
4. Rub y P yt hon :- Ru by IMPLEMENTATION of Python AND WAS devel oped to ru n the Ruby APPLICATION.
5. STACKLESS Pyt hon :- WAS deve loped to i mplem ent conc urren cy in Pyth on.
6. ANACONDA P yt ho n: - WAS de velo ped t o HANDLE AND proce ss th e big DATA.
Python supports AUTOMATI C GARBAGE colle ction. It uses A COMBINATION of reference countin g AND cycle-dete cting
GARBAGE collector for me mory MANAGEMENT AN OPTIMISATION. gc module in pyt hon STANDS for GARBAGE collecto r which
runs from time to time A ND which ever ob ject’s reference count REACHES t o zero, THAT get s GARBAGE collec ted
AUTOMATICALLY. As A user y ou ARE not ALLO WED to interfere in memory MANAGEMENT . It is TAS K of the PVM to MANAGE
the memory. Yes, but if you WANT to chec k whether gc mod ule is ENABLED o r DISABLED or i f you WANT to EN ABLE or
DISABLE it then you MAY use it like bel ow:-
In the ABOVE DIAGRAM, compiler is responsible to comp ile the source code. In the COMPILATION STA GE ALL the
SYNTACTICAL erro rs ARE checked WHEREAS interpreter is responsible to int erpret th e byte code AND chec k the run
time error in this STAGE.
Compiler AND in terpreter bot h ARE TRANS LATOR. C ompiler TRAN SLATES the source c ode to b yte code(.py c file) ALL AT
once WHEREAS interpreter TRANSLATES byte code to mAchine code one instru ction At A time which interActs with
HARDWARE to give the FI NAL output.
Few IMP ORT ANt co mmA nds :-
1. python FILE_NAME.PY —> To run the file
2. python -m py_c ompile FILE_NAME.PY —> To compile the file
3. python -m dis FILE_NAME.PY —> To see the byte co de.
4. python FILE_NAME.CPYTHON-38.PYC —> To run the compi led cod e.
5. PORTABLE AND PLATFORM Indep end en t:- Pytho n is por tAble And plAtf orm ind epend ent bot h. Sou rce cod e is
PORTABLE WHEREAS byte code(.py c fil e) is PLATFORM independent. C is PORTABLE but not PLATFORM indepen dent.
6. DYNAMICALLY typ ed PROGRAMMING LANGUAGE:- In python , every thing i s AN object. Ob jects g et stor ed in the
HEAP AREA AND it’s m emory ADDRESS is re feren ced by the VARIABLE or NAME with which it is b inded . U nlike ot her
PROGRAMMING LANGUAGES, In python, me mory LOCATION does not wo rk li ke A CONTAINER RATHER it works on r efere nce
model. N o need to spe cify th e DATA type expl icitl y in py thon.
7. Ext ens ib le AND Em bed de d bot h - E xte ns ibi li ty - E xtend ing the code from oth er PROGRAMMING LANGUAGES into
Python code. Em be dde d - Embe dding Pyth on co de to othe r PROGRAMMING LANGUAGES code.
8. BATTERIES in clu de d:- Pyt hon c omes with huge LIBRARY support requ ired for f ull USABILITY.
9. Com mun it y S up por t: - Hu ge Py thon commu nity suppo rt AVAILABLE for begin ner, INTERMEDIATE AND ADVANCE level
PROGRAMMERS.
10. CBSE 10t h STANDARD SYLLABUS HAS Python no w.
11. The gro wth AND ACCEPTANCE python HAS shown o ver t he YEARS, is EXCEPTIONAL. Click Here for more DETAILS.
[Re fe re nc es :- ]
1. https://en.wikipediA. org/wiki/Python_( progrAmming_lAngu Age)
1. Sim ple & EASY t o LEARN:- Pytho n is one of t he si mples t LANGUAGE ever. SYNTAXES ARE simple, EASY to re membe r
AND quite e xpres sive. Whe n it co mes to LEARNING, it HAS been fou nd THAT the LEARNING curve for pyt hon is qu ite
steeper COMPARED to other PROGRAMMING LANGUAGES.
SAMP Le Pro grAm in JA Va to ADd two n umb ers :-
public CLASS ADD{
public STATIC void MAIN(STRING[]ARGS){
int A = 10;
int b = 20;
int c = A+B;
System.out.pri ntln(c);
}
}
SAMP Le Pro grAm in Py thon to A Dd two nu mbe rs: -
A = 10
b = 20
c = A+B
print(c)
2. Mo st ex pr es si ve LANGUAGE :- B ein g one of t he m ost e xpr ess ive LANGUAGE is EASY t o wr ite t he c ode i n fe wer
line s, wh ich LEADS to l ess clut ter ed PROGRAM, FASTER executi on AND EASY to deb ug AND MAINTAIN.
3. FREEWARE AND op en s ou rce :- Pyt hon being FREEWARE, you don ’t HAVE to spen d on li censi ng. And since it is
open so urce so it s ORIGINAL source code is fr eely AVAILABLE AND CAN be redistrib uted AND MODIFIABLE.
4. Co mp il ed AND I nt er pr et ed bo th :- ORIGINALLY, Python WAS d evel ope d to bri dge t he GAP be twee n C AND sh ell
scri ptin g AND ALSO inc lud e the FEATURE of ex cep tion HANDLING fro m ABC LANGUAGE. S o we CAN SAY THAT, INITIALLY
Pyth on WAS inte rpr ete d LANGUAGE. But LATER it WAS MADE compiled AND int erp ret ed bo th.
GENERALLY, the steps in volved in execut ion of ANY pytho n PROGRAM ARE -
Python is GENERAL purpose , High level PRO GRAMMING LANGUAGE .
TRADITIONAL PROGRAM MING LANGUA GES like C or C++ were compiled LANGUAG ES. If you ex ecute ANY source co de in C or
C++, it first CREATE S AN EXECUTABLE file which is PLATFORM dependent AND then you run this file to get the
output on THAT PARTICUL AR PLATFORM.
Sour ce Code —> C omp iler —> EXEC UTA BLE Cod e(. exe fi le) —> Out put
You CAN se e here THAT the INTERM EDIATE co de which ARE GENERATED is not PLATFORM independen t. But remember THAT
the Source code written in these LANGUAG ES ARE PORTABLE.
So, to counter this pro blem, LANGUA GES like JAVA And Py thon were develo ped which Are first compiled to obj ect
code or By te co de or P- CODE (P ORTA BLE c ode). These object codes ARE complet ely PLATFORM independent. Now
when you move this obj ect code to other PLATFORM then you need to TRANSLATE it to MACHINE co de. For TRANSLATION
AT this STAGE, you MAY either use compiler or interpreter , ANY TRANSL ATOR which A GAIN TRANSLATE S the byte code to
MACHINE code. For INSTANCE, JAVA, Py PI, JP yth on uses JIT co mpi ler, where CP yth on uses int erp ret er.
Sour ce Code —> C omp iler —> B yte Cod e —> Inte rpr eter or J IT com pil er( PVM /JV M) —> MAC HINE Co de —>
Outp ut
So BASICALLY, we MAY SAY THAT to bri dge the GAP betwee n PORTABLE PROGRAMMIN G LANGUAGES AND P LATFORM in dependent
PROGRAMMING LANGUAGES we CAME up with this IDEA to HAVE two TR ANS LAT ORS. First time it is used to GENERATE
SHIPPABLE code AND seco nd time it is us ed to convert the byte code to MA CHINE code.
[References:-]
1. https://en.wik ipediA.org/wiki /Python_( progrAmming_lAnguAge)
2. https://www.ge eksforgeek s.org/hist ory-of-pyt hon/
3. http://effbot. org/pyfAq/why-wAs-p ython-creAted- in-the-fir st-plAce.htm
4. https://www.ArtimA.com/ intv/pytho n.html
Byte code ARE ALSO CALLED obje ct code or p-code or PO RTABLE code which MAY be be directly shipped to your client.
As well AS i t is PLA TFORM indepe ndent so it CAN run on A NY PLATFORM. Which MA KES service provider's AND
developer's life EASY AS they do not HAVE to write the code for the SAME APPLICATION to be used on different
PLATFORM.
Computer's HARDW ARE ARE electro nic devi ces AND they CAN not UND ERSTAND HUMAN LANGUAGE , RATHER they COM MUNICATE
with EACH other with the help of SIGNALS. SI GNALS Are nothing but BI NARY code And is completely low level
LANGUAGE. To TR ANSL ATE High level lAnguAges in humAn reAdAble formAt to mAchine reAdAble formAt(binAry code),
we need TR ANS LAT ORS.
I. Com pil ed LANGUAGES n eeds co mpi le r to TRANSLATE t he co de wh ereAs Int er pre te d LANGUAGES need s
int erp re ter to TRANSLATE th e cod e fro m one form to ANOTHER.
II. Co mp il er & In te rp re te r b oth ARE TRANSLATOR AND ARE c om pu te rPROGRAMS.
III. Com pil er TRANSLATES t he wh ole c ode f rom o ne fo rm to Anothe r for m ALL AT once whil e i nte rp ret er is
ins tru ct ion by in str uc tio n e xec ut ion .
IV. In Pyth on, Com pi ler is used to trAn slAte Sou rc e c od e to by te co de wher eAs In te rpr et er is us ed to
TRANSLATE the Byte c ode to MACHINE c od e.
V. All SY NTACTICAL e rr or s Are cAu ght At COMPILAT ION stAge i n Pyt hon w her eAs Al l r un ti me e rr or s Are cAug ht
AT INTERPRETATION STAGE.
NOTE :- ORIG INAL LY, Pyt hon is I nte rpr eted LA NGUAG E. But over the tim e, P yth on is MA DE com pil ed A ND
Inte rpr eted both AS py thon HAS E STA BLI SHED i tse lf AS f ull f led ged PROG RAM MIN G LAN GUA GE AND is
ACCE PTA BLE ACR OSS wide A REA of APP LICA TIO N.
[References:-]
1. http s: //e n.w ik ipe diA. org /wi ki /In ter pr ete d_lA nguA ge
2. http s: //w ww. fr eec ode cAmp .or g/ new s/c om pil ed- ver su s-i nte rp ret ed- lAng uAge s/
Error HANDLING is one of the most IMPORTANT FEATURE of Python. It WAS MAIN deciding FACTOR in development of
Python.
There ARE MAINLY two ty pe of errors in Python:-
I. SYNTAX E rr or CAUGHT AT COMPILATION STAGE
II. Run- time Err or CAUGHT AT run t ime or INTERPRETATION STAGE.
SYNT AX & SY NTAC TIC AL Err ors :- Every PROGRAMMING LANGUAGE comes with A set of rules which defines THAT how
the codes will be writte n AND in terpreted or compiled. These set of rules ARE CA LLED SYN TAX. Not following the
rules MAY LEAD to errors which ARE CALLED Syn tAx er ror s. I n P yth on, AT COMPILATION STAGE we check for the
SYNTAX errors. If there ARE no SYNTAX errors in your PROGRAM then it w ill be comp iled successfu lly AND byt e code
will be GENERATED. If there ARE some S YNTAX error in your PR OGRAM then COMPILATION w ill not HAP PEN AND byt e code
will not be GENERATED. S YNTAX Er ror HA PPE NS w hen Py thon CA N’T UN DER STA ND W HAT you A RE SA YING .
Run Time Er ror s:- Run t ime err or HAP PENS w hen Py thon C AN UND ERS TAN D WHAT y ou ARE S AYI NG but ru ns
into p rob lem whi le ru nni ng yo ur i nst ruc tion s. To fin d the list o f ALL run ti me error you MAY execu te the
below code:-
>>> print(dir( “__builtin s__”))
We CAN HANDLE runtime errors using exception HANDLING conce pt in Python unlike SYNTAX errors which HAS to be
rectified before COMPILATION . Run time er rors MAY CAUSE PARTIAL IMPLEMEN TATION of your c ode.
[Reference:-]
1. https://csci rcles.cemc.uwAter loo.cA/1e-errors/
Sour ce Code:- The code, writte n to develop the APPLICATION. In python, (.-)file is source code.
Byte co de:- A fixed se t of instruction s THAT represent s ALL OPERATIONS like ARITHMETIC , COMPARISON, me mory
RELATED OPERATIONS etc. The code GENERA TED AFTER the C OMPILATION of so urce code. (.pyc ) file is byte c ode. Byte
code is system AND PLAT FORM independent. It is ALSO CAL LED p-code, PORT ABLE code or obj ect code.
PVM:- STANDS for Py thon VIRT UAL MAC HINE AND is A SOFTWARE which comes with Python . PVM comes with
Interpreter.
MACH INE code:- The code GENERA TED AFTER INTER PRETATION of byt e code. It is sy stem AND PLATFO RM dependent.
There ARE MAINLY two ty pes of PROGRAMMI NG LANGUAGE.
1. Lo w Le v el PROGRA MMING LANGU AGE
I. MACHINE Level LANGUAGE or BINARYCod e
II. Asse mbly LANGUAGE
2. Hi gh Le ve l PROGRAM MING L ANGUAG E
I. BASED on purpose
i. GENERAL Purpose PL
ii. SPECIAL Purpose PL
II. BASED on convert ers use d
i. Compile d —> C/ C++/JAVA/PYTHON
ii. Interpr eted —> PERL/JAVA Scr ipt/P ython
There ARE MAINLY two ty pes of memory in computer:-
1. VOLATILE Memory - PRIMARY Memory - TEMPORARY STORAGE - RAM, CACHE, Register
2. NON-VOLATILE memory - SECONDARY Memory - PERMANENT STORAGE - HDD, SDD, F loppy , CD, Pen D rive
-> Every PROGRAM runs i nto RAM.
-> SECONDARY memory ARE used for PERMANE NT STORAGE.
A PRO GRAM MING LAN GUAGE is A set of predefined words thAt Are combined into A progrAm According to predefined
RULES(SYNTAX). PROGRAMMING LANGUAG ES ARE used to develop the APPLICATION which helps in turn to get our TASK
done.
An O PERA TING Sys tem is A SOFTWA RE THAT ALLO WS A user t o run other APPLICATIONS on A computin g device. The MAIN
job of OPERATIN G system is to MANAGE comp uter’s SOFTW ARE AND HARDWARE r esources lik e I/O d evice, Networ k device,
STORAGE device etc. AND to run the APPL ICATION on our s ystem AND resour ce ALLOCATION re quired for the SAME .
1. HTTPS:/ /WWW.ANACONDA .COM/PRODUCTS /INDIVIDUAL
2. HTTPS:/ /REPO.ANACONDA .COM/ARCHIVE /

Python introduction

  • 1.
    Python uses DYNAMICtypi ng AND A COMBIN ATION of referen ce counting AND A cycle-detecting GARBAGE collec tor for memory MANAGEMENT. It A LSO FEATURES DYN AMIC NAME RESOLUTION (LATE bindi ng) which binds methods AND VARI ABLE NAMES during PROGRAM execution . As we know, whenever we run ANY APPLICA TION it gets LOA DED into RAM AND some memory get s ALLOCATED by O S for THAT APPLICATION. Fig-1 shows the SAME. Now, Fig-2 shows the different AREA C REATED in the AL LOCATED memory f or running the APPLICATION. Code AREA :- Fi xed in size AND code gets LOADED in this AREA. STACK ARE A:- It MAY grow or s hrink DYNAMICALL Y AND is respons ible for the ord er in which meth od will be resolved. Also in this L OCAL VARIABLE r eference ARE CREATED . HEAP AREA :- This A LSO MAY grow or shrink DYNAMICAL LY AND is respo nsible to store A NY object in Pyt hon. Here object get stored in RAN DOM order. Every object which ge ts stored here w ill HAVE A speci fic ID. GARBAGE collector runs in HEAP AREA from time to time AND destroys the obj ect which ARE no t HAVING ANY re ference. VAR IABLE AREA :- In This section VARIABLES ARE s tored AND they r efer their corres ponding object i n HEAP AREA. Anaconda Installation:- What is ProgrammingLanguage and Operating System and why do we need them? A brief introduction to computer memory Types of ProgrammingLanguages Sl No Low Level Programming Language High Level ProgrammingLanguage 1 More closer towards system, less closer towards user More closer towards user, less closer towards system 2 Need to know the underlying architecture of machine on which you are coding No need to know the underlying architecture of machine on which you are coding 3 Bit complex t o lea rn an d writ e the c ode, no t man age able whe n p rog ra m g rows an d n ot i deal to develop large application Easy to lear n an d write the c ode, easily m anage able when prog ram gr ows and ideal to develo p large application 4 As a programmer you need to manage the memory and handle the security issues in your program Compiler or VM is responsible to manage the memory and handle the security issues your program 5 Code is not portable. Code is portable. 6 Not expressive Expressive 7 e.g. Machine code, Assembly code e.g. C, C++, Java, Python etc 8 Sample code Sample code What is Source code, Byte code and Machine code inPython? Type of Errors inPython:- Compiled Languages vs Interpreted Languages Why do we need translator? Why do we need Byte code? Why Python is compiled and interpreted both? Can’t we make it either compiled or interpreted? What is Python? What are some good features of Python? Memory Management in Python:- Garbage Collection inPython Different Flavours of Python There ARE different FLAV OURS or IMPLEME NTATION of pytho n ARE AVAILABLE . Out of which t he most common ARE: - 1. Cpy tho n: - C IMPLEMENTATION of Python, devel oped to ru n C APPLICATION on PVM, wh ich WAS desi gned using C. 2. Jyt hon :- JAVA IMPLEMENTATION of Python , dev elope d to run JAVA APPLICATION on PVM, w hich WAS de signe d using JAVA. 3. PyP I:- P yth on IMPLEMENTATION of Python. Impl ement s JIT comp iler, to i mprov e the PERFORMANCE of python APPLICATION. 4. Rub y P yt hon :- Ru by IMPLEMENTATION of Python AND WAS devel oped to ru n the Ruby APPLICATION. 5. STACKLESS Pyt hon :- WAS deve loped to i mplem ent conc urren cy in Pyth on. 6. ANACONDA P yt ho n: - WAS de velo ped t o HANDLE AND proce ss th e big DATA. Python supports AUTOMATI C GARBAGE colle ction. It uses A COMBINATION of reference countin g AND cycle-dete cting GARBAGE collector for me mory MANAGEMENT AN OPTIMISATION. gc module in pyt hon STANDS for GARBAGE collecto r which runs from time to time A ND which ever ob ject’s reference count REACHES t o zero, THAT get s GARBAGE collec ted AUTOMATICALLY. As A user y ou ARE not ALLO WED to interfere in memory MANAGEMENT . It is TAS K of the PVM to MANAGE the memory. Yes, but if you WANT to chec k whether gc mod ule is ENABLED o r DISABLED or i f you WANT to EN ABLE or DISABLE it then you MAY use it like bel ow:- In the ABOVE DIAGRAM, compiler is responsible to comp ile the source code. In the COMPILATION STA GE ALL the SYNTACTICAL erro rs ARE checked WHEREAS interpreter is responsible to int erpret th e byte code AND chec k the run time error in this STAGE. Compiler AND in terpreter bot h ARE TRANS LATOR. C ompiler TRAN SLATES the source c ode to b yte code(.py c file) ALL AT once WHEREAS interpreter TRANSLATES byte code to mAchine code one instru ction At A time which interActs with HARDWARE to give the FI NAL output. Few IMP ORT ANt co mmA nds :- 1. python FILE_NAME.PY —> To run the file 2. python -m py_c ompile FILE_NAME.PY —> To compile the file 3. python -m dis FILE_NAME.PY —> To see the byte co de. 4. python FILE_NAME.CPYTHON-38.PYC —> To run the compi led cod e. 5. PORTABLE AND PLATFORM Indep end en t:- Pytho n is por tAble And plAtf orm ind epend ent bot h. Sou rce cod e is PORTABLE WHEREAS byte code(.py c fil e) is PLATFORM independent. C is PORTABLE but not PLATFORM indepen dent. 6. DYNAMICALLY typ ed PROGRAMMING LANGUAGE:- In python , every thing i s AN object. Ob jects g et stor ed in the HEAP AREA AND it’s m emory ADDRESS is re feren ced by the VARIABLE or NAME with which it is b inded . U nlike ot her PROGRAMMING LANGUAGES, In python, me mory LOCATION does not wo rk li ke A CONTAINER RATHER it works on r efere nce model. N o need to spe cify th e DATA type expl icitl y in py thon. 7. Ext ens ib le AND Em bed de d bot h - E xte ns ibi li ty - E xtend ing the code from oth er PROGRAMMING LANGUAGES into Python code. Em be dde d - Embe dding Pyth on co de to othe r PROGRAMMING LANGUAGES code. 8. BATTERIES in clu de d:- Pyt hon c omes with huge LIBRARY support requ ired for f ull USABILITY. 9. Com mun it y S up por t: - Hu ge Py thon commu nity suppo rt AVAILABLE for begin ner, INTERMEDIATE AND ADVANCE level PROGRAMMERS. 10. CBSE 10t h STANDARD SYLLABUS HAS Python no w. 11. The gro wth AND ACCEPTANCE python HAS shown o ver t he YEARS, is EXCEPTIONAL. Click Here for more DETAILS. [Re fe re nc es :- ] 1. https://en.wikipediA. org/wiki/Python_( progrAmming_lAngu Age) 1. Sim ple & EASY t o LEARN:- Pytho n is one of t he si mples t LANGUAGE ever. SYNTAXES ARE simple, EASY to re membe r AND quite e xpres sive. Whe n it co mes to LEARNING, it HAS been fou nd THAT the LEARNING curve for pyt hon is qu ite steeper COMPARED to other PROGRAMMING LANGUAGES. SAMP Le Pro grAm in JA Va to ADd two n umb ers :- public CLASS ADD{ public STATIC void MAIN(STRING[]ARGS){ int A = 10; int b = 20; int c = A+B; System.out.pri ntln(c); } } SAMP Le Pro grAm in Py thon to A Dd two nu mbe rs: - A = 10 b = 20 c = A+B print(c) 2. Mo st ex pr es si ve LANGUAGE :- B ein g one of t he m ost e xpr ess ive LANGUAGE is EASY t o wr ite t he c ode i n fe wer line s, wh ich LEADS to l ess clut ter ed PROGRAM, FASTER executi on AND EASY to deb ug AND MAINTAIN. 3. FREEWARE AND op en s ou rce :- Pyt hon being FREEWARE, you don ’t HAVE to spen d on li censi ng. And since it is open so urce so it s ORIGINAL source code is fr eely AVAILABLE AND CAN be redistrib uted AND MODIFIABLE. 4. Co mp il ed AND I nt er pr et ed bo th :- ORIGINALLY, Python WAS d evel ope d to bri dge t he GAP be twee n C AND sh ell scri ptin g AND ALSO inc lud e the FEATURE of ex cep tion HANDLING fro m ABC LANGUAGE. S o we CAN SAY THAT, INITIALLY Pyth on WAS inte rpr ete d LANGUAGE. But LATER it WAS MADE compiled AND int erp ret ed bo th. GENERALLY, the steps in volved in execut ion of ANY pytho n PROGRAM ARE - Python is GENERAL purpose , High level PRO GRAMMING LANGUAGE . TRADITIONAL PROGRAM MING LANGUA GES like C or C++ were compiled LANGUAG ES. If you ex ecute ANY source co de in C or C++, it first CREATE S AN EXECUTABLE file which is PLATFORM dependent AND then you run this file to get the output on THAT PARTICUL AR PLATFORM. Sour ce Code —> C omp iler —> EXEC UTA BLE Cod e(. exe fi le) —> Out put You CAN se e here THAT the INTERM EDIATE co de which ARE GENERATED is not PLATFORM independen t. But remember THAT the Source code written in these LANGUAG ES ARE PORTABLE. So, to counter this pro blem, LANGUA GES like JAVA And Py thon were develo ped which Are first compiled to obj ect code or By te co de or P- CODE (P ORTA BLE c ode). These object codes ARE complet ely PLATFORM independent. Now when you move this obj ect code to other PLATFORM then you need to TRANSLATE it to MACHINE co de. For TRANSLATION AT this STAGE, you MAY either use compiler or interpreter , ANY TRANSL ATOR which A GAIN TRANSLATE S the byte code to MACHINE code. For INSTANCE, JAVA, Py PI, JP yth on uses JIT co mpi ler, where CP yth on uses int erp ret er. Sour ce Code —> C omp iler —> B yte Cod e —> Inte rpr eter or J IT com pil er( PVM /JV M) —> MAC HINE Co de —> Outp ut So BASICALLY, we MAY SAY THAT to bri dge the GAP betwee n PORTABLE PROGRAMMIN G LANGUAGES AND P LATFORM in dependent PROGRAMMING LANGUAGES we CAME up with this IDEA to HAVE two TR ANS LAT ORS. First time it is used to GENERATE SHIPPABLE code AND seco nd time it is us ed to convert the byte code to MA CHINE code. [References:-] 1. https://en.wik ipediA.org/wiki /Python_( progrAmming_lAnguAge) 2. https://www.ge eksforgeek s.org/hist ory-of-pyt hon/ 3. http://effbot. org/pyfAq/why-wAs-p ython-creAted- in-the-fir st-plAce.htm 4. https://www.ArtimA.com/ intv/pytho n.html Byte code ARE ALSO CALLED obje ct code or p-code or PO RTABLE code which MAY be be directly shipped to your client. As well AS i t is PLA TFORM indepe ndent so it CAN run on A NY PLATFORM. Which MA KES service provider's AND developer's life EASY AS they do not HAVE to write the code for the SAME APPLICATION to be used on different PLATFORM. Computer's HARDW ARE ARE electro nic devi ces AND they CAN not UND ERSTAND HUMAN LANGUAGE , RATHER they COM MUNICATE with EACH other with the help of SIGNALS. SI GNALS Are nothing but BI NARY code And is completely low level LANGUAGE. To TR ANSL ATE High level lAnguAges in humAn reAdAble formAt to mAchine reAdAble formAt(binAry code), we need TR ANS LAT ORS. I. Com pil ed LANGUAGES n eeds co mpi le r to TRANSLATE t he co de wh ereAs Int er pre te d LANGUAGES need s int erp re ter to TRANSLATE th e cod e fro m one form to ANOTHER. II. Co mp il er & In te rp re te r b oth ARE TRANSLATOR AND ARE c om pu te rPROGRAMS. III. Com pil er TRANSLATES t he wh ole c ode f rom o ne fo rm to Anothe r for m ALL AT once whil e i nte rp ret er is ins tru ct ion by in str uc tio n e xec ut ion . IV. In Pyth on, Com pi ler is used to trAn slAte Sou rc e c od e to by te co de wher eAs In te rpr et er is us ed to TRANSLATE the Byte c ode to MACHINE c od e. V. All SY NTACTICAL e rr or s Are cAu ght At COMPILAT ION stAge i n Pyt hon w her eAs Al l r un ti me e rr or s Are cAug ht AT INTERPRETATION STAGE. NOTE :- ORIG INAL LY, Pyt hon is I nte rpr eted LA NGUAG E. But over the tim e, P yth on is MA DE com pil ed A ND Inte rpr eted both AS py thon HAS E STA BLI SHED i tse lf AS f ull f led ged PROG RAM MIN G LAN GUA GE AND is ACCE PTA BLE ACR OSS wide A REA of APP LICA TIO N. [References:-] 1. http s: //e n.w ik ipe diA. org /wi ki /In ter pr ete d_lA nguA ge 2. http s: //w ww. fr eec ode cAmp .or g/ new s/c om pil ed- ver su s-i nte rp ret ed- lAng uAge s/ Error HANDLING is one of the most IMPORTANT FEATURE of Python. It WAS MAIN deciding FACTOR in development of Python. There ARE MAINLY two ty pe of errors in Python:- I. SYNTAX E rr or CAUGHT AT COMPILATION STAGE II. Run- time Err or CAUGHT AT run t ime or INTERPRETATION STAGE. SYNT AX & SY NTAC TIC AL Err ors :- Every PROGRAMMING LANGUAGE comes with A set of rules which defines THAT how the codes will be writte n AND in terpreted or compiled. These set of rules ARE CA LLED SYN TAX. Not following the rules MAY LEAD to errors which ARE CALLED Syn tAx er ror s. I n P yth on, AT COMPILATION STAGE we check for the SYNTAX errors. If there ARE no SYNTAX errors in your PROGRAM then it w ill be comp iled successfu lly AND byt e code will be GENERATED. If there ARE some S YNTAX error in your PR OGRAM then COMPILATION w ill not HAP PEN AND byt e code will not be GENERATED. S YNTAX Er ror HA PPE NS w hen Py thon CA N’T UN DER STA ND W HAT you A RE SA YING . Run Time Er ror s:- Run t ime err or HAP PENS w hen Py thon C AN UND ERS TAN D WHAT y ou ARE S AYI NG but ru ns into p rob lem whi le ru nni ng yo ur i nst ruc tion s. To fin d the list o f ALL run ti me error you MAY execu te the below code:- >>> print(dir( “__builtin s__”)) We CAN HANDLE runtime errors using exception HANDLING conce pt in Python unlike SYNTAX errors which HAS to be rectified before COMPILATION . Run time er rors MAY CAUSE PARTIAL IMPLEMEN TATION of your c ode. [Reference:-] 1. https://csci rcles.cemc.uwAter loo.cA/1e-errors/ Sour ce Code:- The code, writte n to develop the APPLICATION. In python, (.-)file is source code. Byte co de:- A fixed se t of instruction s THAT represent s ALL OPERATIONS like ARITHMETIC , COMPARISON, me mory RELATED OPERATIONS etc. The code GENERA TED AFTER the C OMPILATION of so urce code. (.pyc ) file is byte c ode. Byte code is system AND PLAT FORM independent. It is ALSO CAL LED p-code, PORT ABLE code or obj ect code. PVM:- STANDS for Py thon VIRT UAL MAC HINE AND is A SOFTWARE which comes with Python . PVM comes with Interpreter. MACH INE code:- The code GENERA TED AFTER INTER PRETATION of byt e code. It is sy stem AND PLATFO RM dependent. There ARE MAINLY two ty pes of PROGRAMMI NG LANGUAGE. 1. Lo w Le v el PROGRA MMING LANGU AGE I. MACHINE Level LANGUAGE or BINARYCod e II. Asse mbly LANGUAGE 2. Hi gh Le ve l PROGRAM MING L ANGUAG E I. BASED on purpose i. GENERAL Purpose PL ii. SPECIAL Purpose PL II. BASED on convert ers use d i. Compile d —> C/ C++/JAVA/PYTHON ii. Interpr eted —> PERL/JAVA Scr ipt/P ython There ARE MAINLY two ty pes of memory in computer:- 1. VOLATILE Memory - PRIMARY Memory - TEMPORARY STORAGE - RAM, CACHE, Register 2. NON-VOLATILE memory - SECONDARY Memory - PERMANENT STORAGE - HDD, SDD, F loppy , CD, Pen D rive -> Every PROGRAM runs i nto RAM. -> SECONDARY memory ARE used for PERMANE NT STORAGE. A PRO GRAM MING LAN GUAGE is A set of predefined words thAt Are combined into A progrAm According to predefined RULES(SYNTAX). PROGRAMMING LANGUAG ES ARE used to develop the APPLICATION which helps in turn to get our TASK done. An O PERA TING Sys tem is A SOFTWA RE THAT ALLO WS A user t o run other APPLICATIONS on A computin g device. The MAIN job of OPERATIN G system is to MANAGE comp uter’s SOFTW ARE AND HARDWARE r esources lik e I/O d evice, Networ k device, STORAGE device etc. AND to run the APPL ICATION on our s ystem AND resour ce ALLOCATION re quired for the SAME . 1. HTTPS:/ /WWW.ANACONDA .COM/PRODUCTS /INDIVIDUAL 2. HTTPS:/ /REPO.ANACONDA .COM/ARCHIVE /