Python Detailed Notes
Python Detailed Notes
1. Introduction to Python
- High-level, interpreted, and easy to learn.
2. Python Basics
Variables: x = 10, name = 'Alice'
Data Types: int, float, str, bool, list, tuple, set, dict
3. Operators
Arithmetic: + - * / // % **
Assignment: = += -=
4. Control Structures
If-else: if cond:
5. Functions
def greet(name):
Tuple: (1, 2)
Set: {1, 2, 3}
7. String Operations
s = 'Python'
8. OOP in Python
class Car:
self.brand = brand
def drive(self):
print(self.brand)
obj = Car('BMW')
math.sqrt(25)
print(f.read())
Modes: r, w, a, r+
x=1/0
except ZeroDivisionError:
print('Error')
finally:
print('Done')