+ 2

Can someone explain Functional Programming in Python? (Friendly plz)

I kinda got stuck on Module 7 at the Python course, so I read the comments on the article. But, I got stuck even more. Can you explain Functional Programming in a friendly way?

8th Dec 2020, 6:04 PM
:DD
:DD - avatar
2 Réponses
+ 4
Functional programming is basically converting each step of an algorithm or task into a mathematical function (more or less). Functions that doesn't effect other pieces of value or code and doesn't have internal state are called pure functions. Using this type of functions help to write more secure and readable code. Think of making a cup of tea. At each step of making it you call a function with some parameters and the function returns you a value that you use to continue and perform the next step. 1. GetWater(.5liter); 2. HeatWater(100deg); 3. So on.. Functional programming is a bit cumbersome but it's gaining some popularity with the help of Elixir.
8th Dec 2020, 6:24 PM
Akib
Akib - avatar
+ 1
if you use in your code functions like: def blabla(): do something return something then its functional programming if you use Classes, objects, and methods (which is cool if you get familiar with them) then this is OOP
8th Dec 2020, 6:35 PM
Shadoff
Shadoff - avatar