Focus mode

Python Temel

First Class Function

First Class Function


  • Python'da fonksiyonlar first class function olarak değerlendirilir. Bunun anlamı fonksiyonların diğer veri tipleri gibi manipüle edilebilir ve başka fonksiyonlara argüman olarak verilebilir.


  • Bir fonksiyonu bir değişkene atayabiliriz.


def kare(x):
    return x**2



a = kare


kare(5)


25


a(5)


25
  • Bir fonksiyonu başka bir fonksiyona argüman olarak verebiliriz.
def f2(x, f):
    return f(x) + 4


f2(3,kare)


13


def f3(x):
    return x**5


f2(2, f3)


36

Test

Hackerrank challenge

Comments

You need to enroll in the course to be able to comment!