Coding Introduction

Learn what programming is all about in this super fast introduction!

Welcome

Hello and welcome to our free online course "Introduction to programming". In this course you will learn the basics of programming with Kotlin.

What is kotlin?

Kotlin is the main programming language used to create most Android apps. Once you have learned the basics of Kotlin you can start with Android app development. Also all these basic concepts can be applied to any other programming language.

It's especially similar to Swift, the language used to make iOS apps. This makes it easy to switch later on!

Learning by doing

During this course each lesson will consist of some explanation, we try to keep it as short and sweet as possible. And then a lot of practical exercises.

We believe it's best to learn coding by doing. So lets start with your first program!

Hello world

Every programming instruction starts with a "Hello world" program. The purpose of this program is to make the computer say: Hello world

Take a look at the code. If you press the "Run code" button the program will be executed. After a successful execution the output is displayed underneath the code.

Run the code to see the output!

Hello world explained

Let's take a closer look at the program we just ran. It's a very simple program. Only 3 lines!

A simple program

No need to worry about fun main yet. We'll explain that later in the course. For now just remember that all code you write has to be within the curly braces {}

println

This program writes "Hello world" to the output. It's doing so using the println() function. println() is short for print line As you might expect given the name, it will print 1 line of text to the output followed by a return/enter. The text to print is given between the brackets ()

After the program is executed, everything written to the output will be displayed underneath the code.

Your turn

In the code you see the Hello world program again. For this exercise you will have to modify it to give the correct output.

To edit the program simply select the text you want to change and start typing.

Assignment

Change the output of the program by changing the text between the double quotes ("..."). Can you make it say:

Hello kotlin!

Tips

  • Programs are case sensitive so make sure the output matches exactly.

Printing multiple lines

The println function can be used as much as you want. Everytime you use it, it will print a new line to the output.

Can you make a program that writes 2 lines? The output should look like this:

first
second

Tips

  • Use the println function multiple times for each line you want to print. Scroll back up to the previous exercise if you forgot the syntax.

  • Make sure you didn't forget any quotes " or brackets (). In this case all outputs should be lowercase.

Code comments

Programming can be confusing. Sometimes adding some extra information to the code can really help to understand what's happening.

We can add extra text like that with code comments. Code comments can be extremely useful. In this course we'll be using them to add extra explanations to the code. Comments are only for the programmer and are completely ignored by the computer.

There are two ways to add a comment:

// this is a single line comment

/*
This is a multiline comment
everything between /* */ is a comment.
*/

See the code for some examples. As you can see comments are displayed in green (In this course).

Well done

You wrote your first lines of code and learned how to write output! You also learned how to add comments to your code. Continue to the next lesson to get started with variables.

Summary

  • Kotlin is the main programming language used for making Android apps.

  • If we want to see the results of a program we have to run or execute it. Both terms can be used interchangeably.

  • Every program has a text output channel.

  • println() is used to write text to the output channel.

  • Code comments are used to explain programmers what a piece of code is for. Comments are not executed and the computer ignores them.