Let’s check out some exercises that will help understand Python’s print function better.

Exercise 1-a

Let's start with a long time programming tradition and print "Hello World!" by typing it inside print() function.

Hello World! needs to be in quotes since it’s a text. We will discover this topic in more details during next lessons.

print ("Hello World!")

Exercise 1-b

Now try to assign "Hello World!" to the variable my_text.

Make sure, variable (my_text) is on the left side of the equation. and your string is in quotes while assigning it to my_text, like this: “Hello World!”

When printing a variable with print function you shouldn’t use quotes. But if you’re printing a string directly with print() function then you should.

my_text="Hello World!"

Exercise 1-c

There are many ways to concetenate different data pieces with Python's print() function. Here is one of them. Take a look!

You can use numbers or text as your values. Just make sure it’s inside quotes if it’s a text (we’ll cover this in more detail later) and separated by commas inside the print function.

print("SpaceX", "Blue Origin", "Sierra Nevada")

*Please note that comma inside the quotes serves the purpose of making the output more proper while commas outside the quotes are necessary for print() function and they separate the different values inside the print function.

Exercising is a great way to improve skills and gain confidence. Especially with language studies, repetition and consistent practices are proven ways to success, this is no different for computer languages. We highly suggest progressive repetition if you are a student of Python. 

Speaking of fun, it is also one of the major keys to sustainable practice. If you enjoy what you’re doing everything will be much easier than it would be otherwise.

Check out plenty of exercises, tutorials and other resources we have prepared for you to navigate through this exciting journey.