Python is a versatile programming language used almost in all application development. OO Features coupled with excellent library support makes Python a preferred language for Web Development, IoT Application Development, Data Science and Machine Learning. In this module, we will focus on getting hands-on development and debugging experience of Python, starting with basics. Further will get a deeper understanding of advanced aspects like OO programming, File handling, Package creation, Exception handling. Eventually, you will be able to develop a multitasking application in IoT Gateways.
2. Python
● Combines the features of C and JAVA
● It offers elegant style of developing programs like C
● It offers classes and objects like Java
3. Features of Python
● Simple
● More clarity
● Less stress on reading and understanding the syntax
● Easy to learn
● Uses very few keywords
● Very simple structure, resembles C
● Open source
● High level language
● Dynamically typed
● Type of the variable is not declared statically
4. Features of Python...
● Platform Independent
○ Python compiler generates byte code
○ PVM interprets the byte code
● Portable
● Procedure and Object oriented language
● Interpreted
● Extensible
● Embeddable
● Huge Library
● Scripting Language
● Database Connectivity
○ Provides interfaces to DB like Oracle, Sybase or MySql
6. Memory Management in Python
● In C or C++, allocation and deallocation of memory will be done manually
● malloc(), calloc(), realloc() or free()
● In python, it is done at run time automatically
● Memory Manager inside the PVM takes care of allocating memory for all objects in
Python.
● All objects are stored in Heap
7. Garbage Collection in Python
● Garbage collector is a module in Python that is useful to delete objects from memory
which are not used in the program.
● The module that represents the GC is gc.
● It will keep track of how many times the object is referenced.
● If it is referenced 0 times, then gc will remove object from memory.
8. C Vs Python
C Python
Procedure Oriented language Object Oriented language
Faster Slower
Compulsory to declare the data types of variables Data Types are not required
Type discipline is static and weak Dynamic and strong
Pointers concept present No pointers concept
No exception handling facility Exception handling facility is robust
Do-while is present Absent
Has switch statement No Switch
9. C Vs Python
C Python
Manually allocate the memory Automatic
Absence of GC GC is present
Supports Single and multi dimensional arrays Supports only single dimension
Array should be positive Can be Positive or negative
Array bounds checking is not present Present
Indentation is not necessary Strictly needed
Every statement is terminated by ; No semicolon