Let's start by writing our very first program. It's a very short program that displays “hello world” on the console window. “Hello World” is a tradition of sorts among all programmers, it's always the first program that anyone runs. So welcome to the team.
In the editor window, type this line of text exactly. The word PRINT () is a Python instruction that tells the computer to display something on the screen. In the console area, it should look something like this. Lets run or execute our code by clicking the Run button on the top middle of the screen.
Our goal is to see the exact phrase written between single or double quotes inside the console area. Did it work? If not, there must be a bug in your code. So take another look and check to see if everything is written down correctly. Congratulations, you have officially written your first program check.
Let's modify this tiny program a bit. Let's change the text inside the two single quotes symbols. Write “apples” inside single quotes to add a plus sign, and then write “are red” inside single quotes again. When we run the program, we'll see “apples are red” printed on the console. The characters inside the quotations are called “STRINGS”.
Strings is just another word for a sequence of characters like “hello world” or “apples are red”. Each letter including the space is a character.
We'll explain Strings in more detail as we move forward. An Expert Tip - Python is case sensitive, you must use the correct case size when typing code like “print”.
Let's move forward. Pythons really good at math. It has the ability to do calculations. We call these calculations OPERATORS. The basic Operators include additions, subtraction, multiplication, and division. And we use the same symbols as we do in math class. For example, to multiply two numbers, we use an asterisk symbol between the two numbers. Similarly, we use the “/” symbol to divide the two numbers.
Pause the video and write these programs on lines three to 17 in Repl and execute them. What are the results? As a bonus execute this program, print the sum of four into print nine plus seven minus print 10 divided by zero. What happens?
All right, we now can write tiny programs to do simple mathematical calculations and print the output to the console. Before we move on, let's learn how to add COMMENTS in our Python code. Comments are lines of code that are added to make the code easier to understand for others. However, they're skipped over by the computer and don't actually affect how the code runs.
Comments in Python are added by placing a pound symbol which is also known as a hash symbol. In front of the comment text. We start this program with a Comment. The second line has a print statement and also contains a comment. And the last line of this program is another Comment. All of these Comments aren't executed and then the output of three is printed.
Let's review the concepts that we covered in this first lesson. IDE is a program that will allow us to edit, run and save our code files. Bugs are mistakes or errors in the code that prevent the program from working, debugging fixing mistakes or errors in a code. Strings, a sequence of characters surrounded by single or double quotes like “Hello world”. Great. This brings us to the end of our first unit.
In the next unit. We'll start learning more about Python. However, before you move on to the next unit, set up your Repl console if you haven't done that already and try out all the examples on it. You'll learn to code by coding