

0 / 2 embers
0 / 3000 xp
click for more info
Complete a lesson to start your streak
click for more info
Still calibrating
click for more info
Not enough gems
Cost: 6 gems
1: Welcome to Functional Programming
incomplete
2: Why Python?
incomplete
3: Immutability
incomplete
4: Declarative Programming
incomplete
5: It's Math
incomplete
6: Classes vs. Functions
incomplete
7: Debugging FP
incomplete
8: Functional vs. OOP
incomplete
9: Statements vs. Expressions
incomplete
10: Ternary Expressions
incomplete
11: Functions Practice
incomplete
Next
ctrl+.
This lesson's interactive features are locked, please to keep using them
Functional programming is a style (or "paradigm" if you're pretentious) where we compose functions instead of mutating state. By contrast, imperative programming updates state along the way:
car = create_car()
car.add_gas(10)
print(car.get_gas())
# 10
Functional programming composes functions that return new values:
car = create_car()
car_with_gas = add_gas(car, 10)
gas = get_gas(car_with_gas)
print(gas)
# 10
Each function's output becomes the next function's input. The original car isn't changed, because add_gas just returns a new copy.
In this course, we're working on Doc2Doc, a command line tool for converting documents from one format to another (like Pandoc)... but there's a problem with the stylize_title function.
Before returning the document with the border, call center_title and pass it the document, capturing its return value in the centered_doc variable.