Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (2024)

These are the coding concepts that are taught on Coding Adventure Part 1 and will be reviewed in this article:

  1. Simple Loops (times loop) - challenges 21 - 30

  2. Variables - challenges 31 - 50

  3. Array and Indexes - challenges 51 - 60

  4. For Loops - challenges 61 - 75

A simple loop is a block of instructions that are repeated for a specified number of times. This number is specified together with the command "times", separated by a dot. For example, to write a loop that repeats 3 times, use:
3.times ->

# Your code here

The instructions inside the loop are indented. To indent code, use the tab key.
Using a loop can make your code shorter. For example, in the challenge below, we repeat the same code three times for stepping and turning to catch all the bananas:

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (1)

Instead, we could use a loop!

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (2)

Try it!

Back to Top

A variable can be thought of as a container that holds one value at a time. The value can be any kind of data, for example, number, string, or array. A variable is referred to by a name and its value can be changed.
To assign a value to a variable, use the "=" symbol.

So, in the following code:
x = 10
x is the variable name and 10 is the value assigned to it.
If you want to change the value of x, you can assign a different number to x. For example:
x = 15
Now the value of x is 15.
When you use step with a variable, the computer replaces the variable with its assigned value. Hence, the monkey will step a number of steps according to that value.
Notice: the Variables table at the lower part of the editor (when you run the challenge). It shows the variables and their values. When the value of a variable is changed, it is also updated in the table.

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (3)

Try it!

Variables are powerful when used within loops. In the example below, d is a variable. It is first assigned with a value of 6. Then, in each iteration of the loop (i.e., 3 times) it is increased by 5. Therefore, the values of d will be:
Before the loop: d is 6
After the first iteration: d is 11 (6 + 5)
After second time: d is 16 (11 + 5)
After last time: d is 21 (16 + 5)

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (4)

Try it!

Back to Top

An array is a named collection of items. The items have order in the array. These items are accessed by using square brackets - [ ]. To refer to an item in an array, use the array's name and square brackets, inside the brackets write the index number of the item.

The first index is 0. The last index will be the number of items in the array minus 1 (since the first index is 0).

A commonly used array in CodeMonkey is called bananas. It holds the bananas in a challenge. To refer to the first banana, use bananas[0]; to refer to the second banana, use bananas[1], and so on.
Other examples of arrays in the game are: beavers, crocodiles, turtles, and even bushes.
In the example below, turtles is an array, and we move the turtles by using turtles[0], turtles[1] and turtles[2].

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (5)

Try it!

Back to Top

A for loop is another type of loop. It is used when you have an array and we want to repeat the same action for each item in the array. The for loop will keep going until all the actions were completed on all the items in the array.
The syntax to use a for loop is:
for loop_variable in array_name

# Your code here
The loop_variable is a name we assign; it can be any name we want. It is common to name it after the first letter of the array's name.
When the computer executes a for loop, it first replaces loop_variable with the first item in the array and runs the instructions inside the loop for that item. Then, it continues to the second item in the array, and so on. So, the loop will run as many times as the number of items in the array.

For example, suppose we have an array with 4 bananas, which is called bananas. The names of the items in the array are: bananas[0], bananas[1], bananas[2], bananas[3]. We write the following code:
for b in bananas
turnTo b
step distanceTo b
The first time this loop will run, the computer will replace b with bananas[0]. The actual code that will run is:
turnTo bananas[0]
step distanceTo bananas[0]
Then, b will be replaced with bananas[1]. The actual code that will run is:
turnTo bananas[1]
step distanceTo bananas[1]
Then, b will be replaced with bananas[2]. The actual code that will run is:
turnTo bananas[2]
step distanceTo bananas[2]
Finally, the last run will be:
turnTo bananas[3]
step distanceTo bananas[3]
Note how effective a for loop can be.

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (6)

Try it!

In the example below, the array name is turtles and the loop variable is t. Each time, a different turtle in the array will step 20, and eventually all the turtles will move.

Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (7)

Try it!

Back to Top

Relevant Articles:

How to Access the Challenges' Solutions
Coding Adventure - Coding Concepts part 2

Coding Adventure - Coding Concepts part 3


Coding Adventure Part 1 - Coding Concepts | CodeMonkey Help Center (2024)

FAQs

What is the times loop in CodeMonkey? ›

If we want to repeat a code for a specific number of times, we will use the times loop. The code indented will be repeated per the number specified in the times loop. t is replaced with the number of times to repeat the loop.

What is the concept of CodeMonkey? ›

A code monkey is typically a programmer or developer who is seen as proficient at writing code but who may lack a deep understanding of the overall design or architecture of the project they are working on.

Is CodeMonkey good for kids? ›

CodeMonkey is user-friendly and intuitive, so users can jump right in without any previous coding experience. Our award-winning block based and text based courses are great for children ages 5-14.

How many levels are in CodeMonkey? ›

overview. Join an adorable monkey in an hour-long jungle adventure that will introduce your students to the basics of computer science. In the activity, students will advance through a self-paced progression of 30 challenges in which they will help a monkey catch bananas as they write real lines of code.

What is the endless loop code? ›

The form for (;;) for an infinite loop is traditional, appearing in the standard reference The C Programming Language, and is often punningly pronounced "forever". This is a loop that will print "Infinite Loop" without halting.

What is an array in code monkey? ›

An array is a named collection of items. The items have order in the array. These items are accessed by using square brackets - [ ]. To refer to an item in an array, use the array's name and square brackets, inside the brackets write the index number of the item.

What are loops code? ›

In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached. Typically, a certain process is done, such as getting an item of data and changing it, and then some condition is checked such as whether a counter has reached a prescribed number.

What does return do in coding? ›

Overview. A return statement causes execution to leave the current function and resume at the point in the code immediately after where the function was called. Return statements in many languages allow a function to specify a return value to be passed back to the code that called the function.

What is function make code? ›

A function lets you create a portion of code that you can reuse in your program. This is handy because you can put code that you want to use over again in a function. Instead of copying the same code to many places in your program, you can just use a function you made and all the code inside is used as a single block.

What are functions How are functions declared and parameters passed to functions? ›

Function declaration includes function_name, return type, and parameters. Function definition includes the body of the function. The function is of two types user-defined function and library function. In function, we can according to two types call by value and call by reference according to the values passed.

What code does CodeMonkey teach? ›

CodeMonkey is an AWARD-WINNING online platform that teaches kids real coding languages like CoffeeScript and Python.

What age is CodeMonkey for? ›

While we encourage any person of any age to learn to code on CodeMonkey, our curriculum was created for grades K-8 (ages 4 to 14+).

What is the slang for programmers? ›

Jargon programming terms for ideas, communication and product flow with PMs, management and the client
  • Duck. ...
  • Fear-Driven Development. ...
  • Featuritis. ...
  • Protoduction. ...
  • Satisficing. ...
  • Common Law Feature. ...
  • Heisenbug. ...
  • Higgs Bugson.
Oct 16, 2020

How do you write monkey in code? ›

MONKEY is written as XDJMNL.

How old is CodeMonkey? ›

CodeMonkey was founded in 2014, based on Jonathan's successful experiences in teaching young children to code through playful activities.

References

Top Articles
Latest Posts
Article information

Author: Fr. Dewey Fisher

Last Updated:

Views: 6505

Rating: 4.1 / 5 (62 voted)

Reviews: 93% of readers found this page helpful

Author information

Name: Fr. Dewey Fisher

Birthday: 1993-03-26

Address: 917 Hyun Views, Rogahnmouth, KY 91013-8827

Phone: +5938540192553

Job: Administration Developer

Hobby: Embroidery, Horseback riding, Juggling, Urban exploration, Skiing, Cycling, Handball

Introduction: My name is Fr. Dewey Fisher, I am a powerful, open, faithful, combative, spotless, faithful, fair person who loves writing and wants to share my knowledge and understanding with you.