Python Data Foundations Documentation

A plain documentation-style guide for Python, data handling, visualization, and machine learning basics.

Python Environment and Colab Workflow

This page covers the first workflow patterns: executing Python, checking the runtime, using loops, storing dictionaries, and mounting Drive in Colab.

What you should be able to do
  • Run simple Python statements and see returned values.
  • Use a loop and an accumulator variable.
  • Mount Google Drive when code needs external files.
Reusable patterns
  • A notebook cell displays the value of the last expression.
  • Use print() when you need guaranteed visible output.
  • Colab-specific commands work in Colab, but may need changes in plain VS Code.

Python environment and Colab workflow

Listing 1. Basic arithmetic with variables

a = 10
b = 20
a + b
Expected text output or note
30

Listing 2. Check the Python version

!python --version
Expected text output or note
Python 3.12.13

Listing 3. Code listing 3

total = 0
for i in range (1, 6):
  total += i
print (total)
Expected text output or note
15

Listing 4. Code listing 4

loaded_dict = {"a": 1, "b": 2}
print (loaded_dict)
Expected text output or note
{'a': 1, 'b': 2}

Listing 5. Code listing 5

from google.colab import drive
drive.mount("/content/drive")
Expected text output or note
Mounted at /content/drive

Back to overview