Python Class 9 – Chapter 25 Complete Cheat Sheet
1. What is Python?
Python is a high-level, interpreted programming language created by Guido van Rossum in 1991. It is known for its simple s
2. Features of Python (11 Features)
- Simple
- Interpreted
- Free and Open Source
- Object-Oriented
- Portable
- High-Level Language
- Extensible
- Embeddable
- Large Standard Library
- Dynamically Typed
- Indentation-Based
3. Applications of Python
- Web Development (Django, Flask)
- Data Science (pandas, NumPy)
- Machine Learning & AI (TensorFlow, scikit-learn)
- Desktop GUI Apps (Tkinter, PyQt)
- Game Development (Pygame)
- Automation & Scripting
- Cybersecurity Tools
- Embedded Systems (IoT)
- Mobile App Development (Kivy)
4. Tokens in Python
- Keywords: Reserved words like if, else
- Identifiers: Variable/function/class names
- Literals: Constant values like numbers and strings
- Operators: +, -, *, etc.
- Punctuators: (), {}, :, etc.
5. Variables and Data Types
- Variables store values
- Data Types: int, float, str, bool
- Dynamically Typed: Type auto-assigned
6. Input and Output
- input(): Takes user input (as string)
- print(): Displays output
- Use int(input()), float(input()) to convert input type
7. Operators
- Arithmetic: +, -, *, /, //, %, **
- Comparison: ==, !=, <, >, <=, >=
- Logical: and, or, not
8. Conditional Statements
Use if, elif, else:
if condition:
# code block
else:
# another block
(Make sure to use proper indentation)
9. Loops
Use for loop with range():
for i in range(1, 6):
print(i)
Prints 1 to 5
10. Output-Based Examples
print(3 + 4 * 2) -> 11
print('Hi' + '5') -> Hi5
print(10 // 3) -> 3
print(2 ** 3) -> 8
11. Errors in Python
- SyntaxError: Code typo
- IndentationError: Wrong spacing
- NameError: Using undefined variable
- TypeError: Using wrong data type
12. Comments in Python
- Single-line: Starts with #
- Multi-line: ''' or """
- Used to explain code, make it readable, or disable a line temporarily.