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
5 Best VPNs With WireGuard Support — Updated in 2023
Why are American Express Credit Cards So Expensive?
Nullreferenceexception 7 Days To Die
The UPS Store | Ship & Print Here > 400 West Broadway
Craigslist Campers Greenville Sc
Katmoie
oklahoma city for sale "new tulsa" - craigslist
Poe Pohx Profile
Women's Beauty Parlour Near Me
Ashlyn Peaks Bio
Barstool Sports Gif
Was sind ACH-Routingnummern? | Stripe
C-Date im Test 2023 – Kosten, Erfahrungen & Funktionsweise
Craigslist Alabama Montgomery
Scholarships | New Mexico State University
Where does insurance expense go in accounting?
10 Best Places to Go and Things to Know for a Trip to the Hickory M...
2024 U-Haul ® Truck Rental Review
979-200-6466
Lawson Uhs
Foxy Brown 2025
Beryl forecast to become an 'extremely dangerous' Category 4 hurricane
Acts 16 Nkjv
Drug Test 35765N
Costco Gas Hours St Cloud Mn
Skycurve Replacement Mat
Synergy Grand Rapids Public Schools
Nk 1399
Duke University Transcript Request
Busch Gardens Wait Times
LG UN90 65" 4K Smart UHD TV - 65UN9000AUJ | LG CA
Why comparing against exchange rates from Google is wrong
Perry Inhofe Mansion
Duke Energy Anderson Operations Center
Moses Lake Rv Show
Roto-Rooter Plumbing and Drain Service hiring General Manager in Cincinnati Metropolitan Area | LinkedIn
House Of Budz Michigan
Directions To 401 East Chestnut Street Louisville Kentucky
Tugboat Information
Pp503063
Craigslist Free Manhattan
Booknet.com Contract Marriage 2
'The Nun II' Ending Explained: Does the Immortal Valak Die This Time?
Babykeilani
How the Color Pink Influences Mood and Emotions: A Psychological Perspective
Terrell Buckley Net Worth
Is Chanel West Coast Pregnant Due Date
Great Clips Virginia Center Commons
Mkvcinemas Movies Free Download
Predator revo radial owners
Obituary Roger Schaefer Update 2020
La Fitness Oxford Valley Class Schedule
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.