- Why Do We Need Functions?
Functions provide many benefits:
- Code Reusability: We can use the same code multiple times.
- Easy Maintenance: Changes can be made easily.
- Readability: Code becomes easier to understand.
- Modularity: Large programs can be divided into small parts.
- Easy Testing: We can test each function separately.
5. Predefined Functions
Python already provides some built-in functions. We can use them directly.
Examples:
print("Good Morning")
print(bin(4))
print(bin(5))
Output:
Good Morning
0b100
0b101
- print() displays output.
- bin() converts an integer into a binary string.
Top comments (0)