FUNCTIONS, PYTHON OOPS AND EXCEPTION HANDLING
FUNCTIONS, PYTHON OOPS AND EXCEPTION HANDLING Functions A function is a block of statements used to perform a specific task. Functions allow us to divide a larger problem into smaller subparts to solve efficiently, to implement the code reusability concept and makes the code easier to read and understand. Types of Functions in Python: 1. Built-in Functions These are the functions that come pre-defined with Python. They help perform common tasks like printing, taking input, working with numbers or sequences, etc. Examples: Function Description Example print() Displays output on the screen print("Hello") len() Returns the length of an object len("Python") type() Returns the type of an object type(5) int() Converts to integer int("10") float() Converts to float float("3.14") str() Converts to string str(100) input() Takes input from the user input("Enter name: ") sum() Returns the sum of el...