📚 Reference guide

Variables, Types, and print

Store a placeholder host label, a check count, and a True/False flag, then print them and their types.

Series: Python for small scripts

Based on the official Python documentation. Date checked: November 27, 2026. Script tested on Python 3.13.5.

Series: Python for small scripts, Part 2 of 10. Previous: Part 1: Install Python 3 and Run Your First Script. Next: Part 3: Decisions with if, elif, and else.

TL;DR

Before you start

The finished script

Save this as values.py in that folder:

host = "<host>"
check_count = 3
ok = True

print("Host:", host)
print("Checks:", check_count)
print(f"Status: {check_count} checks, ok={ok}")
print(type(host))
print(type(check_count))
print(type(ok))

When you run it, you should see:

Host: <host>
Checks: 3
Status: 3 checks, ok=True
<class 'str'>
<class 'int'>
<class 'bool'>

Steps

  1. Save and run the script. In the terminal, change into python-scripts and run python3 values.py. Why: you can see the stored values and their types before you change anything. You should see: the seven lines above.
  2. Read the three assignments. host holds text, which Python calls a str. check_count holds a whole number, an int. ok holds True or False, a bool. The angle brackets in "<host>" are ordinary characters; they mark a placeholder, not a real machine name. Why: later steps will combine these values, and each type has different rules.
  3. Look at the f-string. The f before the quotes marks a formatted string literal. {check_count} and {ok} are replaced with the current values. Why: this is the usual way to build one message from several values. You should see: Status: 3 checks, ok=True.
  4. Change a value and run it again. Set check_count to 5 and save the file, then run the script again. Why: a variable keeps the last value you assigned. You should see: Checks: 5 and Status: 5 checks, ok=True.

If it fails

Traceback (most recent call last):
  File "nameerror.py", line 1, in <module>
    print(host)
          ^^^^
NameError: name 'host' is not defined

The File path will show the folder where you saved the file.

Stay safe

Next

Part 3: Decisions with if, elif, and else

Sources

Spot something wrong or outdated? Leave a comment below. Every comment is reviewed to keep these posts accurate.

By commenting, you agree to our Terms of use and confirm this is your own work. Short quotes are fine with a credit and link. Copied, unsafe, or abusive comments are removed. See something copied? Say so here.