call function example 3

This commit is contained in:
Mert Gör 🇹🇷 2023-08-01 22:47:17 +03:00
parent 504135cd93
commit 63dbcd0922
No known key found for this signature in database
GPG key ID: 2100A876D55B39B9

View file

@ -0,0 +1,13 @@
class Sample:
def __init__(self, n):
self.n = n
def __call__(self, x):
return x ** self.n
s = Sample(3)
result = map(s, range(10))
for x in result:
print(x)