Overview and warm-up

Overview and warm-up#

Day 1 connects everyday Python concepts to multidimensional cognitive-neuroscience data.

Today’s notebooks

Today’s questions#

  • Which Python interpreter is actually running my code?

  • Where should a script look for its data?

  • What is the difference between an object, method, and attribute?

  • Which dimensions does my array contain?

  • What exactly disappears when I average over an axis?

Retrieval warm-up#

Exercise 5 (Retrieval warm-up)

Answer before running. Write down both outputs.

values = [1, 2, 3]
alias = values
alias.append(4)

print(values)
participant = {"id": "P01", "scores": [7, 9, 8]}
participant["scores"].append(10)

print(participant["scores"][-1])

We will return to the same mental models throughout the day.

Solution to Exercise 5 (Retrieval warm-up)

The outputs are:

[1, 2, 3, 4]
10

values and alias refer to the same mutable list, so appending through alias is visible through values. The nested score list is also mutable; .append(10) adds an item, and index -1 retrieves the final value.