Lesson 20 of 55
10 mins readPython 1D Arrays (Vectors) & 1-Based Indexing
In Plain English
Vectors in Julia are 1D mutable arrays. Julia uses 1-based indexing by default, aligning naturally with mathematical and scientific indexing conventions.
Deep Dive: How It Works
1-Based Indexing: The first element of array A is A[1], and the last element is A[end].
Mutation Convention (!): In Julia, functions that modify their arguments end with an exclamation mark (push!, pop!, append!, sort!).
Vector Construction: [1, 2, 3] creates a Vector{Int64}. zeros(5) creates 5 Float64 zeros. fill(7, 4) creates [7, 7, 7, 7].
Core Rules to Remember

1-Based Indexing & end: First item is arr[1]; final item is arr[end]; slice with arr[2:end-1].

Mutating ! Convention: Functions with ! (like push!) mutate the collection in place.
Live Interactive Example
Hit Run Code to see it liveVector Operations and Mutations
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
Output Console
Click "Run Code" to view the rendered output.
How it works: 1-based indexing is standard. push! appends to the end; pop! removes from the end.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Append and Access Elements
Create a vector `items = [100, 200, 300]`.
Use `push!(items, 400)`.
Print `"Length: $(length(items)), Last: $(items[end])"`.
1
2
3
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.