Skip to content

Learning Tip

Programming is best learned through practice. Experiment with the notebook by modifying examples, running cells multiple times, and observing how changes affect the output. Making small mistakes and correcting them is an important part of the learning process.

Once you have completed the exercises, we move on to the first core Python commands, starting with the print function.

The Print Statement

In this activity, we begin to explore the use of the print statement. The print statement is a useful and important function in Python because it allows us to extract information from our code and display it on the screen.

This is useful for creating outputs, checking whether code is working correctly, debugging errors, and providing information to a user.

What doesprintdo?

The print function sends information from a Python program to the output area. In a Jupyter Notebook, this output is displayed directly below the code cell after the cell is run.

Why isprintuseful?

The print function is often used when learning Python because it gives immediate feedback. It can show the result of a calculation, display the value of a variable, or help identify where an error may be occurring.

Exercise 1: Print Statement

You now have an opportunity to write and test your own code. Please use Anaconda and Jupyter Notebook to complete the exercise.

Run your code and save the file. You may also want to make note of the steps you followed, the results you obtained, and any errors you encountered.

In the next activity, we will look at how to identify and use variables in Python.