The print statement will be a staple tool in your arsenal, used to display the values of your calculations, show the user important messages, and locate where and why any pesky bugs are occurring.
The output of the print statement can be many data types. A common data type to be printed is the string, which is a combination of characters which can form words and sentences. This is a simple example of a print statement, used to display the message, “Hello World”.
print("Hello World")
>>Hello World
Note that the message we want to display is inside parentheses after the command print. Commands in Python are called functions, and the data inside the parentheses are the function’s arguments. Different functions require different types and amounts of arguments, and you will continue to see this structure throughout the tutorials. The print statement can take any number of arguments, separated by commas, and will print them in a single line.
Also note that the message we want to type is inside quotation marks. These symbols tell Python that each character inside of them form a string. Without them, Python might misinterpret them as variables.
This post only really touched on the basics of the print statement, enough for our purposes. If you would like to learn more, refer to this link: https://realpython.com/python-print/
Thanks for reading! The next tutorial is on variables, which no program worth its salt can operate without.
Challenge:
See if you can print your favorite animal to the console. If you're proud of it, take a picture and send it to the club GroupMe!
Comments