Python:
def greet():
print("Hello!")
def farewell():
print("Goodbye!")
def add(a, b):
print(a + b)
# Dictionary mapping int → function
actions = {
1: greet,
2: farewell,
3: lambda: add(5, 7), # using a lambda wrapper
}
# Using the dictionary
actions[1]() # calls greet()
actions[2]() # calls farewell()
actions[3]() # calls add(5, 7)