What exactly did we do?

What exactly did we do? What is this print thingy? And what are these symbols ( ) ' doing?

Watch out! We are dropping some new terms to explain this.

Python has packaged sets of instructions that perform a specific task into bundles called functions. It gave each of those bundles a name.

print is one such bundle whose task is to display a given input on the screen. 

Python provides many such functions to perform different tasks. Since these functions are built right into the Python language, we call them built-in functions. 

To use the print function in your program, simply type its name followed by parentheses. It displays everything you specify within the quotes in the output box.

print()

Inside the parentheses, we can pass one or more pieces of data as input to functions. In our program, we passed a string as input.

Yes, a string is a fancy name for word(s) that begin and end with a quote. Anything that has 'quotes' around it is a string. We put the word quotes in quotes and made it a string. 🙂

We can use either single quotes or double quotes for a string. They just have to match.

A string can represent any data – names, places, numbers, passwords, sentences, and even gibberish, as long as they are inside the quotes.

Here are some examples of strings:
'This is a string',  "this is another string",  'hello world',  'is',  'also',  "a",  'string'.

If there is nothing inside the quotes, that will make it an empty string like this – ''.

Tinker Time:

  • Use the print() function to display 'this is a string' in the trinket output window.
  • Try to print an empty string.
  • Try printing the phrase – Let's code.
  • Can you print more than one line?
    • Line #1
    • Line #2
COMPLETE THE QUIZ BELOW BEFORE PROCEEDING TO NEXT TOPIC or LESSON.