■ Python Programming — Complete Lecture
Notes (Option C)
1. Introduction to Python
Python is a high-level, interpreted, general-purpose programming language.
Created by Guido van Rossum in 1991, it focuses on code readability and simplicity.
Why Python?
• Simple and easy to learn
• Large community support
• Rich libraries (NumPy, Pandas, TensorFlow, etc.)
• Used in Machine Learning, AI, Data Science, Web Development, Automation
2. Python Syntax Basics
Python uses indentation to define code blocks instead of braces {}.
Example
if 5 > 3:
print("Five is greater than three")
3. Variables and Data Types
Python has dynamic typing — you don't need to specify the type.
• int
• float
• str
• bool
• list
• tuple
• dict
• set
Example
name = 'Ali'
age = 20
price = 99.5
is_student = True
4. Operators
• Arithmetic (+, -, *, /)
• Comparison (==, !=, >, <)
• Logical (and, or, not)
5. Conditional Statements (if-elif-else)
Example:
if score >= 90:
print('A grade')
elif score >= 80:
print('B grade')
else:
print('Needs improvement')
6. Loops
For Loop
for i in range(5):
print(i)
While Loop
count = 1
while count <= 5:
print(count)
count += 1
7. Functions
Functions are defined using def keyword.
def add(x, y):
return x + y
8. Lists and Tuples
• List = mutable
• Tuple = immutable
fruits = ['apple', 'banana']
point = (3, 4)
9. Dictionaries
store key-value data
student = {'name': 'Ali', 'age': 20}
10. File Handling
with open('[Link]', 'r') as file:
print([Link]())
End of Notes ■