Programming from zero

Print your first status message

easyFirst steps Must-do

Problem statement

Every script you write for servers will need to tell you what it is doing. Write a Python program that prints these two lines, exactly as shown:

Health check starting and then Target: web-01.

Save it as check.py and run it with python check.py.

Examples

Example 1

Input: No input.

Output: Health check starting Target: web-01

Hints

Approach

Optimal

A Python program is a text file that Python runs from top to bottom, one line at a time. The print() function takes a value and writes it to the terminal, followed by a new line. Text values are called strings and must be wrapped in quotes, either single or double. Because each print() call ends with a new line, two calls give you two lines of output. To run the file, open a terminal in the same folder and type python check.py (on some systems python3 check.py).

Python
print("Health check starting")
print("Target: web-01")

Follow-up questions

  • Add a third line that prints Checks: 3.
  • Print a line of 20 = characters using "=" * 20.

Frequently asked questions

You most likely forgot the quotes. Without quotes, Python thinks Health is the name of a variable, not text. Put the whole message inside matching quotes.

It depends on the machine. On many Linux servers and macOS, python3 is the right command, while on Windows it is usually python or py. Run python --version to see which one points to Python 3.