+ 16
Why functions considered first class objects in Python
Explain me plz.
4 Antworten
+ 24
Did someone say Functional Programming?
Basically, with first class functions you can use freshest programming paradigm where you hate states and embrace cosmic predestination. If you're interested, look up Functional Programming, possibly learn Haskel or something, end friendships because they cannot see the light in this dark world of state.
+ 11
Because it’s useful to be able to pass functions to functions and return functions from functions, for example for list manipulation via map
+ 5
class Cat:#giving class a name Cat
def __init__(self, color, legs):#def __init__ function, argument are self,color,legs. Self-it is mandatory to put self inside it for access data inside class.color&legs are of variables like name and age
self.color = color#if any function in child class contains function like Cat(x,y) x will be taken as color and y will be as legs count.
self.legs = legs
felix = Cat("ginger", 4)#here color is Ginger and leg is 4
rover = Cat("dog-colored", 4)#color will be dog-colored legs will be 4.
stumpy = Cat("brown", 3)#here color is brown and leg is 3
Very simple:p
(stumpy has 3 legs lol 😂)
0
It is first object in programming we studied.