Class 2
Class 2
1. Introduction
2. Basic Python Syntax
3. String Handling
4. Operators
5. Conditional Statements
6. Looping Statements
7. Control Statements
8. Collections
9. Functions
Syllabus
AdvancedPython
1. Modules
2. Packages
3. File Handling
4. OOPS Concept
5. Classes and Objects
6. Inheritance and Polymorphism
7. Abstract classes and Interfaces
8. Exception Handling
9. RegularExpressions
10. Threading
11. Database Connectivity
12. MongoDB (NoSQL)
13. Python XML and JSON Parser
14. Python Libraries
15. Web Technology
16. Introduction to Python web framework
17. Github
18. AWS – Cloud Computing
19. GCP – Google Cloud Computing
20. Software Testing & Automation
1. Introduction
1.1 What is Python?
Python is an interpreted, high-level, general-purpose programming language.
It is an open source programming language. It is easy to learn and
understand. The application development process using Python is much
faster and easier.
It was created by Guido Van Rossum during 1985-1990. Python first released
in 1991. Python was named for the BBC TV show Monty Python’s Flying
Circus. Latest version of Python is 3.11
1.2 Why Python?
i. It is easy to understand.
ii. Beginner’s language.
iii. Platform independet.
iv. Less line of code.
v. Simple to implement.
vi. Huge libraries support.
vii. GUI programming (Tkinter)
1.3 Python Compilers & Interpreters
1.4 Python Packages
Python was developed by Guido Van Rossum in the December 1989. It was
developed at National Research Institute for Mathematics and Computer
Science in the Netherlands.
Major version of Python:
i) Python 1.0 – January 1994
ii) Python 2.0 – October 2000
iii) Python 3.0 – December 2008
1.4 Features of Python
i. Easy to learn
ii. Easy to read
iii. Easy to maintain
iv. A broad standard library
v. Interactive mode
vi. Portable & scalable
vii. Extendable
viii.Database connectivity
ix. GUI programming
x. Python support functional and structured programming language as well as OOPS.
xi. It can be used as a scripting language or can be compiled as byte code for building large
application.
xii. It provide auto typecasting so there si no eed to define variable type.
xiii.It supports automatic garbage collection.
xiv.It can be easily integrated with other programming language.
1.4 Where Python can be used?
i. Web Devlopment
ii. Artificial Intelligence
a) Machine Learning (ML)
b) Deep Learning (DL)
c) Natural Language Processing (NLP)
d) Artificial Neural Network (ANN)
e) Robotics Programming
iii. Data Science
iv. Desktop Application
v. Website Development
vi. Business Application
1.4 Installing Python in Windows & Linux (Ubuntu)
Python has set of keywords, those are reserved words that can not be used as variable names, function name, or any other
identifier.
33 key words are in Python
and, as , assert, break, class, continue, def, del, elif, except, False, finally, for, from, global, if, import, in, is, lambda, None,
nonlocal, not, or, pass, raise, return, True, try, while, with, yield.
Identifiers: Identifier is the name given to entities like class, functions, variable etc.
Variable: variable stores value/data.
There is a rule in Python to define variable name.
i. A variable name must start with a letter or the underscore character.
ii. A variable name can not start with a number.
iii. A variable name can only contain (a-z, A-Z, 0-9 and _)
iv. A variable name is case sensitive.
v. A variable name can not have special character (!@#$%^&*)
For example:
Invalid variable – 1var, var@
Valid variable – var, var1, _var
Multiple assignment variables:
a=b=c=1
a, b, c = 1, 2, ’CODEbinny’
2.3 Datatype
A data type represent the type of data stored into a variable or memory.
Python has 5 standard datatypes.
i. Number
ii. String
iii. List
iv. Tuple
v. Dctionary
Built in datatypes in Python:
a) None
b) Numeric types: int, float, complex
c) Sequence: str, byte, bytearray, list, tuple, range
d) Sets – set, frozenset
e) Mapping – dict
Get the datatype of a variable:
var_type = type(variable_name)
print(var_type)
2.4 Naming Convention in Python
PEP8 (Python Enhancement Proposal)
th@nks
Tarique Ejaz