1. Variables
Definition
A variable is used to store a value that can be used later in the program.Example
Output
Explanation
Variables hold data such as numbers, text, or Boolean values.2. Variable Naming Rules (snake_case)
Rules
- Use letters, numbers, and underscores (
_) - Cannot start with a number
- Cannot contain spaces
- Cannot use special characters except
_ - Case-sensitive (
ageandAgeare different) - Use snake_case for readability
Good Examples
Bad Examples
Output
Explanation
Use meaningful lowercase variable names separated with underscores.3. Assign Multiple Values
Multiple Variables
Output
Explanation
Assign multiple values in a single line.Same Value to Multiple Variables
Output
Explanation
All variables point to the same value.4. Output Variables
Output
Explanation
print() displays the value stored in a variable.
Printing Multiple Variables
Output
Explanation
Separate multiple values using commas.5. Global Variables
Output
Explanation
Global variables can be accessed inside functions.6. Local Variables
Output
Explanation
Local variables exist only inside the function.7. Python Comments
Single-line Comment
Output
Explanation
Python ignores comments.Multi-line Comment
Output
Explanation
Triple quotes are commonly used for multi-line comments or docstrings.8. Indentation
Output
Explanation
Indentation defines code blocks in Python.9. Basic Input
Sample Input
Output
Explanation
input() always returns a string.
10. Taking Integer Input
Sample Input
Output
Explanation
Useint() to convert input into an integer.
11. Basic Output
Output
Explanation
print() displays text or values.
12. Escape Characters
Output
Explanation
Escape characters create special formatting.13. Python Data Types
Integer
Output
Explanation
Stores whole numbers.Float
Output
Explanation
Stores decimal numbers.String
Output
Explanation
Stores text.Boolean
Output
Explanation
Stores True or False.14. Python Numbers
Output
Explanation
Python supports integers, floats, and complex numbers.15. Type Conversion (Casting)
Output
Explanation
Casting converts one data type into another.16. Strings
Output
Explanation
Strings store characters enclosed in quotes.String Indexing
Output
Explanation
Index starts from 0.String Slicing
Output
Explanation
Slicing extracts part of a string.Common String Methods
Output
Explanation
Methods perform operations on strings.17. Booleans
Output
Explanation
Boolean values are either True or False.18. Arithmetic Operators
Addition
Subtraction
Multiplication
Division
Floor Division
Modulus
Exponent
19. Order of Operations
Output
Explanation
Parentheses have the highest priority.20. Comparison Operators
Output
Explanation
Compare two values and return True or False.21. Assignment Operators
Output
Explanation
Assignment operators modify existing values.22. Logical Operators
Output
Explanation
Logical operators combine Boolean expressions.23. Identity Operators
Output
Explanation
is checks whether two variables refer to the same object.
24. Membership Operators
Output
Explanation
Check whether a value exists inside a collection.25. Bitwise Operators
Output
Explanation
Bitwise operators work directly on the binary representation of integers.26. Getting the Data Type
Output
Explanation
type() returns the data type of a variable.
27. Multiple print() Arguments
Output
Explanation
print() can display multiple values separated by commas.