Focus mode

Python Temel

Birden Fazla Değer Döndürme/input İçerme

Birden Çok Input


  • Fonksiyonların birden çok parametresi olabilir.


def square(x):
    return x *x


square(3)


9



def power(x, y):
    
    return x ** y

power(2, 3)


8


Birden Çok Değer Döndüren Fonksiyonlar

def f(x):
    
    return 2*x, 10*x


f(10)



(20, 100)


  • Bana sonucu tuple olarak döndürdü.


  • Variable Unpacking kısmında gördüğümüz gibi bu iki değeri farklı değişkenlere eşitleyebilirim.


a, b = f(10)


a


20


b


100


def f(x,y):
    
    return 2*x*y, (10*x)**y


f(10,2)



(40, 10000)



Test

Comments

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