Lesson 14 of 55
9 mins readPython Positional, Default & Keyword Arguments
In Plain English
Julia cleanly separates positional arguments from keyword arguments using a semicolon (;). Keyword arguments are called by name and provide clear API readability.
Deep Dive: How It Works
Positional Default Arguments: function f(x, y=10) allows calling f(5) or f(5, 20).
Keyword Arguments: Declared after a semicolon in the signature: function f(x; scale=1.0, offset=0.0). Called using name=value (e.g. f(5, scale=2.0)).
Dispatch Difference: Multiple dispatch in Julia dispatches solely on positional argument types, not keyword arguments.
Core Rules to Remember

Semicolon Keyword Boundary: Arguments after ; in function signatures are keyword-only arguments.

Keyword Calling Syntax: Call with func(x, key=value) for explicit clarity.
Live Interactive Example
Hit Run Code to see it livePositional Defaults and Keyword Arguments
Python 3.12
1
2
3
4
5
6
7
8
9
10
11
12
13
Output Console
Click "Run Code" to view the rendered output.
How it works: 0.5*10*400 = 2000; 10*9.81*5 = 490.5; 2000 + 490.5 = 2490.5 J.
Your Turn: Micro Challenge
No pressure! Edit the starter code below and test your solution with instant feedback.
Micro Exercise
Function with Keyword Multiplier
Define a function `scale_value(val; factor=2.0)` that returns `val * factor`.
Print `scale_value(15.0, factor=3.0)`.
1
2
3
4
5
6
Sandbox Output
Click "Run & Check" to test your solution.
Finished reading and practicing?
Mark this lesson as completed to update your course progress.