Python & Networking Notes - Class 12
Review of Python I
Tokens in Python: Keywords, Identifiers, Literals, Operators, Punctuators.
Variables & Data Types: int, float, str, bool, complex.
Operators:
- Arithmetic: +, -, *, /, //, %, **
- Relational: ==, !=, <, >, <=, >=
- Logical: and, or, not
Conditional Statements: if, if-else, if-elif-else
Loops:
- while loop
- for loop
- Loop control: break, continue, pass
Review of Python II
Strings: Immutable, Methods: upper(), lower(), find(), replace(), split(), etc.
Lists: Mutable, Methods: append(), insert(), remove(), sort(), reverse()
Tuples: Immutable, Can contain mixed data types
Review of Python III
Dictionaries: Unordered, mutable key-value pairs
Methods: get(), keys(), values(), items(), pop(), update()
Type Conversion: int(), float(), str(), list()
Intro to Functions (prelude to UDFs)
User Defined Function in Python
Definition: Created using def keyword.
Types:
- Without return value
- With return value
- With/without parameters
Arguments: Positional, Keyword, Default, *args, **kwargs
Python & Networking Notes - Class 12
Scope: Global vs Local variables
File Handling in Python
open(filename, mode): Modes - 'r', 'w', 'a', 'rb', 'wb'
Reading: read(), readline(), readlines()
Writing: write(), writelines()
Closing: file.close()
With statement: with open('file.txt') as f:
Exception Handling in Python
try, except, else, finally blocks
Example:
try:
a = 10 / 0
except ZeroDivisionError:
print("Cannot divide by zero")
finally:
print("Done")
Common Exceptions: ZeroDivisionError, ValueError, IndexError, FileNotFoundError
Data Structure Using Python List
List: Ordered, mutable collection
Operations: Indexing, Slicing, append(), insert(), pop(), remove(), del, index()
Traversal: for item in list
Nested Lists: List within list
Stack Using Python List
LIFO: Last-In-First-Out structure
push: stack.append(item)
pop: stack.pop()
Applications: Undo functionality, expression evaluation
Python & Networking Notes - Class 12
Computer Networking
Definition: Interconnection of computers for sharing data.
Types: PAN, LAN, MAN, WAN
Components: Modem, Router, Switch, Hub
Topology: Bus, Star, Ring, Mesh
Transmission Media: Wired and Wireless
Network Protocol & Application
Protocols: TCP/IP, HTTP/HTTPS, FTP, SMTP, POP3, IP, DNS
IP Addressing: Static and Dynamic, IPv4 & IPv6
Applications: Email, Web browsing, File Sharing, Video Conferencing