Introduction
The print function
3. Hello World explained
Variables
Math in Python
The input function
Summary

Instruction

Good. You could see that the text Hello, World! appeared in our console output. We used the following code for that:

print('Hello, World!')

Let's analyze what happened:

  1. print() is a function. Functions are reusable fragments of code with unique names and pairs of parentheses. Inside the parentheses, we provide arguments. If you know Excel, you can probably recognize this syntax.
  2. print() is used to show text in the console output. Whatever is put inside the parentheses will be displayed to the user.
  3. 'Hello, World!' is a string. In the world of programming, strings are text values. In Python, strings must be surrounded with either single quotation marks ('Hello, World!') or double quotation marks ("Hello, World!"). Best practice is to always use single quotation marks. The quotes are never printed to the user – they only denote the start and end of a string.

Exercise

Modify the template so that it shows the following text:

I want to learn Python!

Stuck? Here's a hint!

Simply write:

print('I want to learn Python!')