Python

Updated: 27 September 2025

Run a python script inside a file

python3 my-script.py

Run a python script as if were an executable program

#!/usr/bin/env python3

from datetime import datetime

now = datetime.today().strftime('%Y-%m-%d %H:%M:%S')
print(now)

Format a number with 2 decimal places

aws_may = 123.5678
print(f"AWS bill for May £{aws_may:.2f}")
# AWS bill for May £123.57

Get type of a variable

print(type(balance))