Displaying Text

In Python to display a text on the screen, we must use the print() function.

for example to display a line of text we must insert the text between the print function parenthesis.

print("Hello World")

 

Using single and double quotes

Python will also display text if you use single quotation marks (The apostrophe character) passed through the print function. Both of the examples below will work perfectly.

print('I am Groot')

print("My name is... Slim Shady")

 

Look at the example below of a quote within a string to see how this can be useful.

print('He say. "One and one and one is three." Got to be good looking because he so hard to see.')

There are other ways to do this but we will look into this later in part 2 of displaying text.

Strings and integers

At this point it is important to know that Python treats data between quotation marks as a string (alphanumeric characters). If we pass a number between quotation parenthesis, Python will treat the numbers as a string (as alphanumeric characters). If we pass numbers into the print function without using quotation marks, Python will treat the characters as integers.

Try the 2 examples below in the Python editor underneath.

print(2+2)

print('2+2')

 

Posted in Uncategorized.

Leave a Reply

Your email address will not be published. Required fields are marked *


*