Unit 1: Introduction to Python
Introduction to Python
History of Python: Python was created by Guido van Rossum in 1991. It emphasizes code readability
and simplicity.
Need of Python: Python is versatile, easy to learn, and supports multiple programming paradigms.
Features of Python: Simple syntax, interpreted, dynamically typed, portable, extensive libraries.
Applications of Python: Web development, data science, AI/ML, automation, game development,
networking.
Standard Data Types
1. Basic Type
Includes text (str), numbers, etc.
Example: name = 'Python'
2. None Type
Represents absence of value.
Example: x = None
3. Boolean Type
Contains True/False.
Example: flag = True
4. Numbers
Types: int, float, complex.
Example: a = 10; b = 10.5; c = 3+4j
Type Conversion
str(), int(), float() etc.
Example: int('10') → 10
Operators in Python
Types: Arithmetic, Relational, Logical, Assignment, Bitwise, Identity, Membership
Operator Precedence: *, / have higher precedence than +, -
Fundamentals of Python Programming
Identifiers
Names for variables, functions etc.
Variables
Used to store values. Example: x = 5
Keywords
Reserved words like if, else, while.
Comments
Single-line: # comment
Multi-line: ''' comment '''
Expressions & Statements
Expression: 2+3; Statement: x = 5
Input and Output
Input Example: name = input('Enter name: ')
Output Example: print('Hello', name)
Flow Control Statements
Conditional Statements
if, elif, else
Looping Statements
for loop, while loop
break, continue, pass
break stops loop, continue skips, pass does nothing.