Chapter 4: The Function Forge

You step into a vast underground forge, where rivers of molten syntax light the dark halls. Metallic creatures hammer pure logic into sharp, reusable tools. Floating anvils carry glowing glyphs that pulse with the rhythm of reusability.

A voice echoes through the chamber: β€œShape the flame. Forge your tools. Master the function.”

"The code obeys the forged will. Define your function β€” define your power."

The Function Forge

πŸ”¨ Puzzle 1: Forge Your First Tool

Define a function greet() that prints "Welcome to the Forge", then call it.



    
    
    

Hint: Start with def greet():, then indent print("Welcome to the Forge") and don’t forget to call greet().

πŸ”₯ Puzzle 2: The Echo of Arguments

Write a function echo(msg) that prints the message given. Call it with "Fire burns!"



    
    
    

Hint: Use def echo(msg): then print msg inside the function and call echo("Fire burns!").

βš™οΈ Puzzle 3: The Blacksmith's Return

Create a function add(a, b) that returns their sum. Print the result of add(3, 4)



    
    
    

Hint: Use def add(a, b): return a + b then print(add(3, 4)).

πŸŽ–οΈ Rune of Returns

As the final line of code is forged, a glowing glyph rises from the anvil. It pulses once - a perfect loop closed. "You have learned to shape tools and wield return."