Why functions are needed
π Scenario: Imagine you are organizing a small party and need to greet each guest with the same message. Instead of writing the greeting again and again, you can use a function to say hello to each guest easily.
π― Goal: You will create a simple function to greet guests by name and then use it multiple times to show why functions help us avoid repeating code.
π What You'll Learn
Create a function called
greet that takes one parameter called nameInside the function, print the message
Hello, [name]! using the parameterCall the
greet function three times with the names 'Alice', 'Bob', and 'Charlie'Print the greetings to the console
π‘ Why This Matters
π Real World
Functions are used everywhere in programming to organize tasks and reuse code, like sending messages, calculating totals, or drawing shapes.
πΌ Career
Understanding functions is essential for any programming job because they help write clean, efficient, and maintainable code.
Progress0 / 4 steps