Introduction to Python Resources

Begin your free Python journey now,
at your own pace

check

Syntax: Printing

check

Examining values at any time with the Python print function.


Printing Outputs

One of the most fundamental parts of learning programming in any computer language is learning how to output values from a program so that the validity of those values can be confirmed. Python includes an easy to use function which provides that functionality. Look below at the code from the previous exercise:

  print("Hello, World!")

The print( ... ) part of the code above tells Python to call a function named print and to output the message written in between the parentheses to the interpreter. print is a built-in function that is always available in Python. print is a function you will get a lot of practice with as it is incredibly useful for outputting messages and values from your applications.

Time to Practice

  1. Open your Python interpreter.

  2. Use the print function to output the following messages:

    1. Print out the greeting, "Hello there!"
    2. Print out a message introducing yourself to someone by telling your name.
    3. Print out a message letting someone know your age.
HINT*: Click here for a hint
*Hints are best viewed after completing a task, or after spending some time and effort attempting it. In cases where a hint contains example output, it is important to understand why it is correct, as there may be many correct outputs.
> 

"Hello there!" "My name is Obi-Wan Kenobi." "I am 30 years old."

SOLUTION*: Click here for an example solution
*Example solutions are best viewed after completing a task and understanding the outcome. In most cases, there are multiple ways to complete a task, and the example solution is only one example.
  print("Hello there!")

> "Hello there!"

  print("My name is Obi-Wan Kenobi.")

> "My name is Obi-Wan Kenobi."

  print("I am 30 years old.")

> "I am 30 years old."

Once you have completed the above, you are ready to move on to the next exercise!