Core Concepts II

Learn to Code Today!

Learn 10x faster: coding, no-code and data skills. Join millions of users mastering new tech skills and accelerating their career with Enki.
Get started

This is part of “An intro to Coding” series of posts, with content from the Enki app. If you stumbled upon this, you can start from the beginning.

Another way to think of functions is as mini-programs within a program.

If a program is a list of tasks for the computer, a function is a list of subtasks for one of those tasks.

In fact, a program is just the starting function that is using other functions.

This allows us to use other programs within our programs as functions.

Perhaps someone wrote a smart program called shortest_path that calculates the quickest path from point A to point B.

If we wanted, we could use shortest_path as a function in our new food delivery application to show the delivery driver's route.

Conditions

It's time to introduce the core tools for making logical decisions and repeating commands within programs.

In computers, there's no maybe. Every question is answered with a yes or a no¹. Every choice with a do or don't.

Imagine that you were writing an app to control a lightbulb. The core of your logic would be a binary decision. If the switch is on, the bulb shines light, otherwise it doesn't.

💡 In fact, the word if is the essential tool in most programming languages for writing conditional yes/no logic.

Loops

Loops allow a program to do a command any number of times.

Picture playing your favorite song on repeat. The command play is looped over every time the song is finished.

We only have to write the command play once and then use a loop to repeat it until a user presses stop.

💡 Loops let us repeat doing a command any number of times


Footnotes

[1] The language of computers is made up of two letters, the 0 and the 1.

Even though computers have such a simple alphabet, they can still do incredible things, like show you this text that you're reading right now.

About Enki

  • Fully personalized online up-skilling
  • Unlimited AI coaching
  • Designed by Silicon Valley experts

More articles

Meet your AI-enabled coach

Professional athletes have a coach for every aspect of their performance. Why can’t you for your work? Enki’s AI-powered coaching on-demand - combined with state of the art, structured learning content - makes this a reality.
1
1:1 AI Coaching
How do I remove duplicate emails?
Convert the list to a set and back to a list. Sets automatically remove duplicates.
2
Personalized Exercises
3
Interactive practice

Unlock full access to all skills on Enki with a 7-day free trial

Get started