Functions are reusable blocks of code, Arguments are the actual data inputs passed into them, Modules are files containing Python code used to organize projects.
1. Functions:
A Python Function is a self-contained block of code designed to perform a specific task. Functions help break large programs into smaller, organized, and reusable parts to prevent repetitive code.
# Defining a function
def Tech():
return "Hello, welcome back!"
# Calling the function
print(Tech())
Explanation:
- def is the keyword used to define a function.
- Tech is the function name.
- () indicates that the function takes no arguments.
- return sends the result back to the caller.
- print(Tech()) calls the function and displays the returned value.
2. Arguments:
- Arguments are the concrete values you pass into a function when calling it.
(Note: Parameters are the variable names inside the function definition, while arguments are the real values mapped to them).
Positional Arguments: Assigned based strictly on the order they are passed.
def greet(name):
print(name)
greet("Vinoth")
- Keyword Arguments: Passed explicitly using the parameter_name=value format, meaning order does not matter.
def student(name, age):
print(name, age)
student(age=21, name="Vinoth")
- Default Arguments: Fallback values defined in the function signature if an argument is missing during the call.
def greet(name="Guest"):
print(name)
greet()
greet("Vinoth")
- Arbitrary Arguments (*args and **kwargs): Allow a function to accept a dynamic, flexible number of inputs.
def total(*numbers):
print(sum(numbers))
total(10, 20, 30, 40)
3. Modules:
A Module is simply a file containing Python statements and definitions (ending in .py) that you can import into other scripts. Modules let you logically organize your code base and share functionality across different files.

- Built-in Modules: Python comes pre-packaged with useful standard modules like math, random, or datetime.
- Custom Modules: You can create your own file (e.g., mymodule.py) and import it elsewhere using import mymodule.
Top comments (0)