Glossary

Syntax

Syntax refers to how code is structured in a programming language.

For example, the syntax for creating a list in Python is a comma-separated sequence of values enclosed by square brackets:

[1, 2, 3, 4, 5]

Built-in

Relevant session -Relevant session - Session 1

If something is built-in then it is either available by default, or can be accessed without installing any third-party software. In Python, there are various built-in functions such as print or type, as well as built-in modules that can be imported without explictly installing them separately such as math.

Modules and packages

Relevant session - Session 1

A module is a collection of code that may be built-in or external to a given programming language. Packages are usually written for a specific purpose and can contain multiple modules and/or submodules For example the scipy package contains various functions and constants that are helpful for scientific applications.

Function calls

Relevant session - Session 3

Whenever a line of code uses a function, this is referred to as a function call. For example:

import math

math.sin(math.pi / 2)

We say that the second line above calls the math.sin function.

Data structures

Relevant session - Session 2

A data structure is an object that allows us to store and retrieve data in an ordered or otherwise structured manner. Lists, tuples, dictionaries and numpy arrays are all data structures that allow us to sort, order and index data in various different ways.

Docstrings

Relevant session - Session 3

A docstring is a string that is used to document a function. It is typically placed immediately after the definition of the function and is enclosed in triple quotes ("""). The purpose of a docstring is to provide a description of what the function does, as well as any arguments it takes and any return values it produces.

Elements and items

Relevant session - Session 2

Each value in an ordered sequence of any kind is referred to as an element or item. For example, in the tuple below:

(5, 10, 15, 20, 25)

\(10\) is the second element.

Indices

Relevant session - Session 2

An index is a integer that represents the position of a given item in an ordered sequence such as a list. For example:

['a', 'b', 'c', 'd', 'e', 'f']

Here 'c' is located at index \(2\). Remember that Python, and many other programming languages, start counting from zero, so 'a' is at index \(0\), 'b' at index \(1\) etc.

When you access the elements of a list or other structure using square brackets, you are said to be indexing this list.

Iterable

Relevant session - Session 4

An iterable is an object that can be looped over (iterated over) using a for loop. Examples of iterables include list, tuple, str, and dict. When we use a for loop to iterate over an iterable, we are said to be iterating over this iterable.

Sequence

Relevant session - Session 4

A collection of ordered objects where each object has an associated integer index that defines its position in the sequence.

Examples of sequences in this course are str, list, tuple, and numpy arrays. When we access the elements of a sequence using square brackets, we are said to be indexing this sequence.

Mutability

Relevant session - Session 2

Mutable objects can be changed after they have been created, while immutable objects cannot be changed after they have been created. For example, list is a mutable data structure, while tuple is an immutable data structure. This means that you can change the contents of a list after it has been created, but you cannot change the contents of a tuple after it has been created.

Scope

Relevant session - Session 3

The scope of a variable refers to the region of a program where this variable is defined and can be accessed. For example, if a variable is defined inside a function, then this variable is said to have local scope and can only be accessed within this function. If a variable is defined outside of any function, then this variable is said to have global scope and can be accessed from anywhere in the program.

Operator

Relevant session - Session 1

An operator is a symbol that performs a specific operation on one or more operands. For example, the + symbol is an operator that performs addition, while the * symbol is an operator that performs multiplication. In Python, there are various types of operators including arithmetic operators, comparison operators, logical operators, and assignment operators.