InterviewHubPRO
Section Overview
Q23

Question 23 of 65

Part 2: Python Core Language, Internals & Runtime (6 - 25)

35%
Python & FastAPI•Part 2: Python Core Language, Internals & Runtime (6 - 25)

First-Class Functions:

In Simple Words: In Python, functions are first-class citizens: they can be passed as arguments, returned from other functions, assigned to variables, and stored in data structures.

python
def shout(text): return text.upper()
def whisper(text): return text.lower()

def format_message(formatter_fn, msg):
    return formatter_fn(msg)

print(format_message(shout, "hello")) # HELLO