MCA
FUNCTIONS & MODULES // MASTER THE CONCEPTS // WRITE BRUTAL CODE // FUNCTIONS & MODULES // MASTER THE CONCEPTS // WRITE BRUTAL CODE //
BACK TO SYLLABUS
EASY

FUNCTIONS & MODULES

Function definitions, parameters, and module imports

CONCEPTS

01Function definition (def)
02Arguments and keyword arguments
03Return values
04Scope (local vs global)
05Lambda functions
06Importing modules (import, from)

SYNTAX_DEMO

Creating reusable blocks
def greet(name, greeting="Hello"):
    return f"{greeting}, {name}!"

print(greet("Bob"))
print(greet("Alice", greeting="Hi"))

# Lambda function
square = lambda x: x * x
print(square(5))

import math
print(math.sqrt(16))