Level One: Let’s Get Coding in Python!

Let’s get coding in Python right of the bat! Every powerful software starts with just one line of code, and you’re about to write yours!

Here is an example of a simple program that consists of only one line. All it does is print the message: “Hello! This is my first line of code!”

Enter this line into the compiler and run the code:

print("Hello! This is my first line of code!")
Code
Run
#write code here

If you did it right, the compiler will respond with the following message: Hello! This is my first line of code!

Did it work? Congratulations on your first line of code!

Even if you don’t understand everything yet, don’t worry. We will figure it all out and learn as we go through the course.

Let’s continue!

What Is a Computer Program?

We just created a whole program, even if it was just a teeny one line. Pretty cool, right? Think of it like building your first mini-game or app!

But hold up, what exactly is a program anyway?

A program is a set of instructions and rules for a computer written in a programming language. Think of a program as a cooking recipe, it tells a computer what to cook and how to cook it, step by step.
Does it make sense? Awesome, let’s cook then! Let’s go on and reinforce what we have learned.

Here is the code I’ve shuffled. Your task is to fix it and make it work.

"Let me cook!" () print
Code
Run
#write code here

If you put it right, you should get a program that prints a sentence that says “Let me cook!”

Did you nail it? Great! Both programs that we have just built use a print function. We will use this function a lot in this course. So, let’s dive a little deeper into it.

Print Function

The print function is pretty straightforward: it prints text on the screen. To show users some messages like “Oops, wrong password” or “New password can not be an old password.”

But It’s not just for text messages, though; the print function can also display numbers, like the results of calculations. We’ll get into more of that later. For now, let’s focus on using the print function to see how it works.

Here’s a simple task: use the print function to display this message:

Hey! I keep coding!
Code
Run
#write code here

Run your code, and that’s exactly what should appear on your screen.

So, now that you’ve learned how to use the print function, feel free to experiment! Try printing our different messages. Include numbers, emojis, and any words you like.

And even change your code around, and see how your program responds. It’s a great way to learn how coding works.

How a Computer Reads Your Code?

When you run your code, the computer starts reading it just like you’d read a post – line by line, from the top and all the way down.

It might not seem like a big deal, but it’s important for how we organize our code. For example, stuff like modules (we will learn about them in later lessons) need to be at the beginning of your code. We insert them up front so the program can see and call them throughout the code.

To illustrate what I’m saying, let’s write a small program that counts from one to three to see how Python reads a code line by line, from top down. Here is the code:

print("1")
print("2")
print("3")

Enter this code into the compiler and run it.

Code
Run
#write code here

Does the program count to three? Pretty simple, right? Now, go ahead and extend the code so that the program can count to 10.

If you’ve done everything right, your program will count to ten and stop.

Did it work? Great job! Have a cookie, and let us proceed!

Level One Quiz

You have to pass the quiz to complete Level One!

Level One Quiz

1 / 4

 A computer program is a:

2 / 4

How do we display a message on a screen?

3 / 4

In what order does a computer process (read) the code?

4 / 4

Choose the line of code that has no errors.

Your score is

The average score is 63%

0%


Wrapping Up Level One: Let’s Get Coding in Python!

In Level One, you accomplished the following:

  1. Learned what Python is;
  2. Learned what a program is;
  3. Understood how Python reads code;
  4. Wrote your first line of code;
  5. Created several simple programs;
  6. Learned how to use the print function.

Way to crush it! You’re ready to tackle Level Two: Variables in Python! Let’s dive in and keep coding!


Python Online is an online compiler where you can write, run, and check your code without installing any software.