Table of Contents Python Developer 3 Real-Time Application developed by Using Python Language. 3 Features of Python. 4 1. Simple. 4 2. Freeware and Open Source. 4 Freeware: 4 Open Source: 5 Some of the Distributions of Python are. 5 3. Platform Independent 5 4. Dynamically Typed. 5 1. Static Typed Programming Languages. 5 2. Dynamically Typed Programming Languages. 5 5. Interpreted Programming. 6 6. High-Level Programming. 7 a) Low-Level Programming Languages: 7 b) High-Level Programming Languages. 7 7. Robust (Strong ) 7 8. Extensible. 7 9. Embedded. 7 10.Extensive Support for Third Party APIs. 8 Literals & Variables in Python. 8 1. Literals in Python. 8 2. Identifiers or Variables in Python. 9 Data Types in Python. 10 I. Fundamental Category data Types. 10 II. Sequence Category data Types. 10 III. List Category data Types. 10 IV. Set Category data Types. 10 V. dict Category data Type. 11 VI. NoneType Category data Types. 11 I. Fundamental Category data Types. 11 1. int 11 a) Decimal Number System.. 12 b) Binary Number System.. 12 c) Octal Number System.. 13 d) Hexa Decimal Number System. 13 2. float 14 3. bool 15 4. complex. 16 II. Sequence Category data Types. 17 1. str 17 1.Single Line String Data: 18 2.Multi-Line String Data: 18 3.Operations on str data type. 19 IV. Set Category data Types. 22 1. set (mutable and Immutable) 22 a) Empty Set 22 b) Non-Empty Set 23 2. Pre-defined Functions in set 23 1. add() 24 2. remove() 24 3. discard() 24 4. pop() 25 5) copy(): 26 6) isdisjoint() 27 7) issubset() 28 8) issuperset() 28 9) union() 28 10) intersection() 28 11) difference() 29 12) symmetric_difference() 29 13) update() 30 3. frozenset 30 pre-defined Functions in frozenset 31 V. Dict Categeory Data Types. 32 a) Empty dict 32 b) Non-Empty dict 33 c) Pre-defined functions in dict 35 1) clear() 35 2) pop() 35 3) popitem() 36 4) copy() 36 5) get() 37 6) keys() 37 7) values() 38 8) items() 38 VI. Flow Control Statements in Python. 39 1. Conditional or Selection or Branching Statements. 39 1. Simple if statement 40 2. if..else statement 41 3. if..elif..else statement 44 4. match case statement (Python 3.10) 45 2. Looping or Iterative or Repetitive Statements. 48 1. while Loop (or) while … else Loop. 49 2.for Loop (or) for …else Loop. 52 3.Transfer flow statements. 55 1.break statement 55 2.continue statement 57 Python Developer ========================================================= Real-Time Application developed by Using Python Language ========================================================= With Python Programming language, we develop around 22 Real-Time applications. They are Web Application DevelopmentJava PL——Servlets, JSP, JSTL, Spring,C#.net PL——-ASP.NET Python PL—–>Django, Flask, Pyramid—Code–Simple Gaming Applications Desktop applications (GUI Applications) Image Processing Applications Business Application Development Audio and Video Based Applications Web Scrapping / Web Harvesting Applications Data Visualization Data Analysis and Data Analytics Scientific Applications Complex Math calculations. Software Development Operating System Installers CAD and CAM Based Software. Embedded System Applications IOT-Based Applications Console-Based Applications. Language Development Automation of Testing Animation applications Education Programs. Computer Vision. Features of Python Language features are nothing but Services or facilities provided by language developers in the languages and used by programmers for developing real-time applications. Python programming Provides 11 features. They are Simple Freeware and Open Source Platform Independent Language Dynamically Typed Interpreted Programming Language High-Level Programming Language Both Procedural and Object-Oriented Programming Language. Robust (Strong) Extensible Embedded Supports Third Party APIs such as Numpy, Pandas, matplot lib, scipy and scikit 1. Simple Python is one of the simple programming language because of 3 important Technical Features. They are Python Programming Provides “Rich Set of APIs”. So that Python programmer can re-use the pre-defined code without writing our code Definition of API (Application Programming Interface): An API is a collection of MODULES. A Module is a collection of Attributes, Functions, and Class Names Examples: calendar, math, cmath, random, gc ….etc Python Programming Provides In-built facility called “Garbage Collector” and whose role is to collect Un-Used Memory space and Improves the Performance of Python Based Applications. Definition of Garbage Collector: A Garbage Collector is one of the In-built program in python software and which is running in the background of our regular Python Program and whose role is collecting Un-Used Memory space and Improves the Performnace of Python Based Applications. Hence Garbage Collector takes care about Automatics Memory Management. Python Programming Provides User-Friendly Syntax’s . So that we can develop error-free programs and Limited span of time. 2. Freeware and Open Source Freeware: If any software is said to be Freeware iff It can be downloaded freely from official websites. Python Software Open Source: The standard Name of Python is called “CPYTHON” Some of the company vendors came forward and Customized “CPYTHON” and used the customized versions as In-house tools in their companies. Such Type of Customized versions of python are called “Distributions of Python” Some of the Distributions of Python are 1) Jpython or Jython —> Used for Running Java Based Applications 2) Iron Python or Ipython —>Used to Run C#.net applications 3) Micro Python —>Used to develop micro controllers. 4) Ruby Python —>Used to Ruby Based Applications 5) Anakonda Python —>Used to Run Hadoop Applications / Big Data Applications. 3. Platform Independent Platform means type of OS being Used for running or executing the Program An Application or Language is said to be Platform Indepenedent iff whose Programs runs on Every OS. Languages Comparison C,C++ …etc——>Platform Dependent—-Data types of C,C++ are size restricted. Java—————->Platform Independent–objects with limited values Python————>Platform Independent–objects with unlimited values Objects–Data Storage All values in python are stored in the form of Objects and objects are independent from OS. 4. Dynamically Typed In the context programming languages, we have two types of languages. They are 1. Static Typed Programming Languages. 2. Dynamically Typed Programming Languages. 1. Static Typed Programming Languages. In These Programming Languages, Programmer must define a variables with Data Type otherwise we get Compile Time Error Examples: int a,b,c; —Variable Declaration —Mandatory a=10 b=20 c=a+b Examples:- C, C++, JAVA, .NET ..etc 2. Dynamically Typed Programming Languages. In These Programming Languages, Programmer need not to specify the data type of the variables. So that data type of Variable decided by Python Execution Environment based value assigned by Programming Examples: >>> a=10 >>> b=1.2 >>> c=a+b >>> print(a,type(a))——————–10 <class ‘int’> >>> print(b,type(b))——————–1.2 <class ‘float’> >>> print(c,type(c))——————–11.2 <class ‘float’> Examples: Python Hence All values in Python Programming are stored in the form of Objects. 5. Interpreted Programming When we develop any python program, we must give some file name with an extension .py (FileName.py). When we execute python program, two process taken place internally a) Compilation Process b) Execution Process. In COMPILATION PROCESS, The python Source Code submitted to Python Compiler and It reads the source Code, Check for errors by verifying syntaxes and if no errors found then Python Compiler Converts into Intermediate Code called BYTE CODE with an extension .pyc (FileName.pyc). If errors found in source code then we error displayed on the console. In EXECUTION PROCESS, The PVM reads the Python Intermediate Code(Byte Code) and Line by Line and Converted into Machine Understable Code (Executable or binary Code) and It is read by OS and Processer and finally Gives Result. Hence In Python Program execution, Compilation Process and Execution Process is taking place Line by Line conversion and It is one of the Interpretation Based Programming Language. Definition of PVM ( Python Virtual Machine) PVM is one program in Python Software and whose role is to read LINE by LINE of Byte Code and Converted into Machine Understable Code (Executable or binary Code) 6. High-Level Programming In general, we have two types of Programming languages. They are a) Low Level Programming Languages. b) High Level Programming Languages. a) Low-Level Programming Languages: In These Programming Languages, we represent the data in lower level data like Binary, Octal and Hexa decimal and This type data is not by default understanble by Programmers and end users. Examples: – a=0b1111110000111101010 —binary data b=0o23—–octal c=0xface—-Hexa Decimal b) High-Level Programming Languages. In These Programming Languages, Even we represent the data in lower level data like Binary, Octal and Hexa decimal , the High Level Programming Languages automatically converts into Decimal number System data, which is understanble by Programmers and end-users and python is one High Level Programming Language. Example : Python 7. Robust (Strong ) Python is one of Robust (Strong) bcoz of “Exception Handling”. Exception:- Runtime Error of the Program are called Exceptions =>Exception by default generages Technocal Error Messages Exception Handling:- The process of converting Technical Error Messages into User Friendly Error Messages Exception Handling. If the Python program uses Exception Handling the Python program is Robust. 8. Extensible The Python programming giving its programming facilities to other languages and hence Python is one of the extensible Programming language. 9. Embedded Python Programming can call other languages coding segments for fastest execution Example: Python code can call C programming Code. 10.Extensive Support for Third Party APIs As Python Libraries / API can do many tasks and Operations and unable perform complex operations and to solve such complex operations more easily and Quickly we use Third Party APIs such as 1) numpy—-Numerical calculations 2) pandas—Analysis tool 3) matplotlib—–Data Visualization 4) scipy 5) scikit Literals & Variables in Python 1. Literals in Python Literals in Python are nothing but Values passing to the Python Program. Programmatically, when we write any python program, we must enter inputs and such are called Literals or Values. Hence all types of values are called Literals. In Python Programming, we have 5 Types of Literals. They are 1. Integer Literals 2. floating Point Literals 3. Str Literals 4. Boolean Literals 5. Collection Literals. 2. Identifiers or Variables in Python When we enter input oir literals, they are stored in main memory by allocating sufficient amount memory space with help of data types. To Process the data which was stored in main meory, as a programmer, we must some distinct names and these names makes us to identify the values stored in memory space and hence names are called “Identifiers”. The values of Identifiers are changing or variying during program execution and hence Identifiers are also called “Variables”. Hence All types of Input or Literal must be stored in the form of Variables. All Types of Variables are called Object. Definition of Variable: A Variable is an Identifier whose value can be changed during execution of the program. Rules for Using Identifiers or Variables in Python Program: To use Variables in Python Program, we must follow the following rules. 1. The Variable Name is a combination of Alphabets, Digits and a special Symbol Under Score ( _ ) only. 2. The First Letter of Variable Name must starts either with an Alphabet or Under Score. Examples: —————- 1abc=23—–Invalid sal123=45—valid _sal=4.5—valid $sal=4.5–invalid _123=5.6–valid _123_=5.6–valid _sal_=56–valid 3. No Special Symbols are allowed within Variable Name except Under Score ( Note # is used for Commenting in Python ) Examples: sal=45–valid emp sal=5.6—Invalid sal#emp=56–valid ( sal is 45 printed) sal-emp=56–invalid sal$emp=67–invalid a#sal=45—-Invalid bcoz variable ‘a’ is not defined earlier(NameError) 4. No keywords to be used as Variable Names ( Key words are reserved words in programming languages and they gives specific meaning to compilers). Examples: else=45—-invalid bcoz ‘else’ is key word else1=56–valid if=45–invalid bcoz ‘if’ is key word _if=56–valid int=67—–Valid, boz all class names are not keywords 5. All Variable names are Case Sensitive. Examples: >>> age=19—–valid >>> AGE=20———valid >>> Age=21———valid >>> aGe=22—–valid print(age,AGE,Age,aGe)—19 20 21 22 6. It is walys recommended to take user-friendly variable names Examples: totsalsalaryofanemployee=45—–Valid but not recommended tot_sal_emp=45–valid and Recommended. Data Types in Python The purpose of Data Types in Python is that “To allocate sufficient amount of memory space for storing the values or Literals in main memory (RAM) of computer”. In Python Programming 14 data types(classes) and they are classified into 6 categories. I. Fundamental Category data Types a) int b) float c) bool c) complex II. Sequence Category data Types a) str b) bytes c) bytearray d) range III. List Category data Types (Collections Data Types or Data Structures ) a) list b) tuple IV. Set Category data Types (Collections Data Types or Data Structures ) a) set b) frozenset