UNIT 1
UNIT 1
Functions in Python
• A function is a block of reusable code that
performs a specific task. It helps in organizing
code and improving reusability.
Functions in Python
•Built-in Functions: Python provides many built-in functions like len(), print(), type() etc. .
• Types of Imports
• Import Entire Module: import math_utils
• Import Specific Functions: from math_utils
import add
• Rename Module: import math_utils as mu
• Import All Functions: from math_utils import *
Packages in Python
• A package in Python is a collection of modules organized in a directory
with an __init__.py file. It helps in structuring large programs by grouping
related modules together.
Variables & Data Types
• Python automatically detects data types.
• Example:
• x = 10 # Integer
• y = 3.14 # Float
• name = 'AI' # String
• is_valid = True # Boolean
Variables & Data Types
• Numeric Data Type
• Mapping Type
• Boolean Type
Introduction to Control Structures
2.
Exception Handling in Python
• Exception handling is a mechanism that allows a program to
handle errors gracefully instead of crashing. It helps in
debugging and ensures smooth execution.