Skip to Main Content

Python for Basic Data Analysis

Start your data science journey with Python. Learn practical Python programming skills for basic data manipulation and analysis.

The print function

The print function is arguably the most used function in Python. It shows the user vital information about the code on the screen as an output. We have seen how it works in Section1.1 when we printed "Hello, World!".

There are many methods of using print. We will introduce 3 in this section.

Syntax

print()


We need to pass a parameter/argument* to the function by typing it in the parentheses  ( ) . Here, the parameter/argument is a string data "Hello, World!". More about strings in Section 1.4.

print("Hello, World!")

*Parameter vs Argument

The terms parameter and argument are usually used interchangeably to refer to information passed to the function. 

Method 1 - Printing a data value

In this method, we are passing a data value - "Hello, World!" - directly to the function.

Method 2 - Assign data to a variable

In this method, we first assign "Hello, World!" into a variable called message. We then pass the variable into the print function. 

Method 3 - Concatenate

This method uses concatenation, which means putting strings together. We use the  +  operator, and we can do this with as many  +  separating different strings within the print function.

Note that when we use  +  to combine the strings together, you may need to insert a space in between the strings. 

Video Guides

Exercises

Using all 3 methods shown above:

1. Print "Hello, World!".

2. Print "Hello! I am Anna and I am excited to learn Python Programming!" 

Click the triangle button to run the codes and see the output: