What are Functions? | Kodable Help Center (2024)

In programming, we often use the same code more than once to repeat actions or add onto in order to execute more complex tasks. Functions allow us to teach the computer how to do something one time and easily reuse the code later. Students are introduced to functions in planet Moongarden.

Definition: A function is a sequence of commands that can be reused together later in a program.

Functions name the sequence of commands and dictate what code is executed. Functions also allow for separation of code, so we can easily use it again throughout a program.

Programmers often say; Don’t Repeat Yourself. You can think of this as an acronym to help you understand the purpose of functions: keep your code DRY!

What are Functions? | Kodable Help Center (1)

Real life Example: As people, we are always learning and building on what we already know and can do. We add to a foundation to complete more complex processes in life- this is a lot like a function: piecing basic actions together to carry out more complex tasks.

In sports you can think about dribbling a soccer ball - putting together running and kicking, and naming it as one new action: Dribbling.

A great example of this in the classroom is “Criss Cross Applesauce”: we piece together separate actions to make one and name it something that students will remember. Students will learn it once and continue to use it throughout the school year.

Criss Cross Applesauce Function:

What are Functions? | Kodable Help Center (2)

Once students learn “criss-cross applesauce”, we don’t have to instruct them step by step each time each time we say it- students know what to do when they hear it.

Programming Example:

In programming, functions allow us to repeat a sequence of code without having to write the code over again. This allows us to simplify a complex action by using only one command, just like in our criss-cross applesauce example.

During the final part of each functions lesson, students will independently practice identifying patterns of commands that are used more than once in the mazes.

In Kodable, students will use functions if they recognize the same pattern used repeatedly. They can store commands once and reuse them when needed.

What are Functions? | Kodable Help Center (3)

Our code to complete the maze is shortened and we avoid repeating ourselves by using the function twice to complete the maze. We command our fuzz to go Right, use our FUNCTION: which is up, right up, Right, we use our FUNCTION again, and Right. Instead of having to use 9 commands, we only use 5 and we earn 3 stars!

Just like this, we can teach the computer how to carry out a sequence of steps for one specific action in a computer program. We name it so we can use it later when we want the computer to do it again.

For example, if we want to write a program that brings up a window that says “hello,” to a user, we can write a function for it. Since there are two commands that the computer will need to carry out to do this, a function will prevent us from having to instruct the computer step by step each time we want it to say hello:

What are Functions? | Kodable Help Center (4)

First, we name the function “Print and alert”, because that is what we want the computer to do and we’ll need to use the name of our function to do it again later.

What are Functions? | Kodable Help Center (5)

Instead of having to write code for each step the next time we want the computer to perform this task, we just call the function “print and alert” and the computer will automatically bring up the window that says “hello.”

What are Functions? | Kodable Help Center (6)

Why We Use Functions: Functions allow us to teach the computer how to do something one time and easily reuse the code to do it again later. Remember, Don’t Repeat Yourself!

What are Functions? | Kodable Help Center (2024)
Top Articles
Crypto Might Be the Future of Finance. But That's Not Why Most People Buy It
Sustainable finance
Jack Doherty Lpsg
No Hard Feelings (2023) Tickets & Showtimes
AllHere, praised for creating LAUSD’s $6M AI chatbot, files for bankruptcy
Melson Funeral Services Obituaries
Loves Employee Pay Stub
³µ¿Â«»ÍÀÇ Ã¢½ÃÀÚ À̸¸±¸ ¸íÀÎ, ¹Ì±¹ Ķ¸®Æ÷´Ï¾Æ ÁøÃâ - ¿ù°£ÆÄ¿öÄÚ¸®¾Æ
Rabbits Foot Osrs
25X11X10 Atv Tires Tractor Supply
Davante Adams Wikipedia
Hendersonville (Tennessee) – Travel guide at Wikivoyage
Minn Kota Paws
Snarky Tea Net Worth 2022
Devourer Of Gods Resprite
1Win - инновационное онлайн-казино и букмекерская контора
Socket Exception Dunkin
Https E24 Ultipro Com
Busted Newspaper S Randolph County Dirt The Press As Pawns
Best Food Near Detroit Airport
Love In The Air Ep 9 Eng Sub Dailymotion
Busby, FM - Demu 1-3 - The Demu Trilogy - PDF Free Download
Slope Tyrones Unblocked Games
CANNABIS ONLINE DISPENSARY Promo Code — $100 Off 2024
Ratchet & Clank Future: Tools of Destruction
If you bought Canned or Pouched Tuna between June 1, 2011 and July 1, 2015, you may qualify to get cash from class action settlements totaling $152.2 million
The Largest Banks - ​​How to Transfer Money With Only Card Number and CVV (2024)
Keci News
Kirsten Hatfield Crime Junkie
Meridian Owners Forum
Bolsa Feels Bad For Sancho's Loss.
Page 2383 – Christianity Today
1773x / >
Danielle Ranslow Obituary
Unity Webgl Car Tag
Sams Gas Price Sanford Fl
Trust/Family Bank Contingency Plan
Pfcu Chestnut Street
R3Vlimited Forum
Rvtrader Com Florida
Solve 100000div3= | Microsoft Math Solver
1400 Kg To Lb
Edward Walk In Clinic Plainfield Il
Lake Dunson Robertson Funeral Home Lagrange Georgia Obituary
How To Customise Mii QR Codes in Tomodachi Life?
Jackerman Mothers Warmth Part 3
Brutus Bites Back Answer Key
Makes A Successful Catch Maybe Crossword Clue
Phumikhmer 2022
Kobe Express Bayside Lakes Photos
Latest Posts
Article information

Author: Allyn Kozey

Last Updated:

Views: 5441

Rating: 4.2 / 5 (43 voted)

Reviews: 90% of readers found this page helpful

Author information

Name: Allyn Kozey

Birthday: 1993-12-21

Address: Suite 454 40343 Larson Union, Port Melia, TX 16164

Phone: +2456904400762

Job: Investor Administrator

Hobby: Sketching, Puzzles, Pet, Mountaineering, Skydiving, Dowsing, Sports

Introduction: My name is Allyn Kozey, I am a outstanding, colorful, adventurous, encouraging, zealous, tender, helpful person who loves writing and wants to share my knowledge and understanding with you.