Displaying text
We'll begin with the most popular way of introducing any programming language; you'll learn how to display some text in the Python console. The console is a tool that's part of every Python editor, which shows the information we want or displays any errors that occurred (let's hope not to get any!).
The easiest way to show something in our console is to use the print()
method, just like this:
# Displaying text
print('Hello world!')
The text above print
, starting with #
, is called a comment. Comments are excluded when executing code and are only visible to you.
After running this short code in Google Colab, you'll see this displayed:
Hello world!
In conclusion, just put what you want to display into the brackets of the print
method – text surrounded by quotes, as in this example, or variables.
If you're curious about what variables are, that's great – you'll learn about them...