Your first program in Python
Topic 1 of 58 · 5 minFree lessonA program is a list of instructions for a computer. The computer follows them one line at a time, from top to bottom.
Python is a language for writing those instructions. It is popular because it reads a lot like English. That makes it a great first language.
Showing a message
Your first instruction is print(). It shows whatever you put inside the brackets.
print("Hello, world!")The text inside the quotes is called a string. You'll learn much more about strings soon. For now, remember that text needs quotes around it. You can use double quotes " or single quotes '. Both work the same way.
More than one line
Each print() shows its message on a new line. Python runs the lines in order, top to bottom.
print("Good morning!")print("Let's learn Python.")print("One step at a time.")Printing numbers
Numbers don't need quotes. Python can even do the math for you before it prints.
print(7)print(2 + 3)Notice the difference quotes make. With quotes, Python prints the text exactly as you typed it. Without quotes, it works out the answer.
print("2 + 3")print(2 + 3)NameError.print(Hello)Put quotes around the text and it works: print("Hello").
print works, but Print and PRINT do not. Always write print in lowercase.Try it yourself
Run the code in the editor and answer 8 practice questions on your first program. It's free, you only need an account.