Imagine if you had to explain how to bake a cake every single time someone asked for one. It would be exhausting! In programming, a FUNCTION is a way to save a set of instructions under a single name. At FLORA WORLD CODING, we think of functions like "MAGIC SPELLS." You define the spell once, and then you can cast it whenever you need it by simply calling its name.
To create a function in Python, we use the DEF keyword (short for define). After the name of your function, you use parentheses () and a colon :. Any code indented underneath that line belongs to the function. To run that code later, you "call" the function by typing its name with parentheses. This structure helps keep your code organized and prevents you from repeating yourself, which is a core principle in software engineering called **DRY** (Don't Repeat Yourself).
Functions are the building blocks of every major application. When you click a "Like" button on a social media app, it triggers a function. When you jump in a video game, thatβs a function. By mastering DEF, you are learning how to build modular, professional code. This level of organization is exactly what Google AdSense reviewers look for: it proves you are teaching logical, scalable programming habits rather than just simple scripts.
DEFINE A FUNCTION CALLED GREET_USER() THAT ASKS FOR A NAME USING INPUT() AND THEN PRINTS A PERSONALIZED GREETING. CALL YOUR FUNCTION THREE TIMES IN A ROW. NOTICE HOW YOU ONLY HAD TO WRITE THE LOGIC ONCE!