Datatypes

When we output text using the print() function, we are displaying what is known as a string. We use different types of name for different types of data.

Text String
A whole number Integer
A number with decimals Float

A string can contain alphanumeric, numeric and also symbol characters. The only rule is that they must be placed inside a set of quotes " ".

<aside> 💡 So another rule you need to learn is that quotes can be in the form of double quotes " " or they can be in the form of single quotes ' ' . These are basically just a set of apostrophe.

</aside>

for example:

https://codapi.org/embed/?sandbox=python&code=data%3A%3Bbase64%2CKyjKzCvRUPJUSMxVcC%2FKzy9R0uQqAIupI8TUNQE%3D

What if I wanted to use an apostrophe or a quote in my string?

For example what if I wrote print('I'm Groot') ?

Python would think that the string would start at the first apostrophe and end at the second. It would cause an error because it would not be sure about what the remainder of the text was.

https://codapi.org/embed/?sandbox=python&code=data%3A%3Bbase64%2CK6gsycjP01D3VM9VcC%2FKzy9R1wQA

We can get around this in 2 ways:

1. Mixing and matching Quotes (not Recommended)

The first method is that you can use double quotes for the above example where a apostrophe is used in the sentence.

print("I'm Groot")