Ana sayfa Genel Python – Fonksiyonlarda Parametre Türleri

Python – Fonksiyonlarda Parametre Türleri

1605
87
PAYLAŞ

Fonksiyonlarda Parametre Türleri

Bu derste fonksiyonlara parametre vermenin farklı yollarını öğrenmeye çalışacağız. İsterseniz hemen başlayalım.

Parametrelerin Varsayılan Değerleri

Biliyorsunuz önceki konularda şöyle bir fonksiyon tanımlamıştık.

Ancak biz eğer bir parametrenin değerini varsayılan olarak belirlemek istersek, bunu varsayılan değerler ile yapabiliriz. Varsayılan değerleri anlamak için selamla fonksiyonunu varsayılan parametre değeri ile yazalım.

İşte bu kadar ! Peki birçok parametreye sahip olursak ne olacak ? Bir fonksiyon daha tanımlayalım.

Ancak böyle bir durumda argümanları gönderirken değerleri sıralı vermemiz gerekiyor. Peki sadece numara parametresine değer vermek istersek ne yapacağız ?

Aslında biz varsayılan değerleri kursumuzun en başlarında görmüştük. print fonksiyonunun sep parametresini hatırlayalım.

Esnek Sayıda Değerler

Biliyorsunuz bir fonksiyon yazıldığında özel olarak kaç tane parametresi olacağını önceden belirtmemiz gerekiyor. Örneğin, bir toplama fonksiyonu yazalım.

Eğer bu fonksiyonu 4 argüman alacak şekilde tanımlamak istersek, tekrardan tanımlamamız gerekiyor.





Peki ben bir fonksiyonu esnek sayıda argümanla kullanmak istersem ne yapacağım ? Bunun için de Yıldızlı Parametre kullanmam gerekiyor. Kullanımı şu şekildedir;




print fonksiyonunu tekrar hatırlayacak olursak aslında print fonksiyonu bu şekilde tanımlanmış bir fonksiyondur. Çünkü biz print fonksiyonuna istediğimiz sayıda argüman gönderebiliyorduk.



Bu konuda gördüğümüz gibi Python’ın bu özelliklerini kullanarak daha esnek fonksiyonlar yazabiliriz. Bir sonraki konuda Global ve Yerel değişkenleri öğrenmeye çalışacağız.

 

87 YORUMLAR

  1. hello!,I really like your writing so so much!
    share we be in contact more about your post
    on AOL? I require an expert on this space to resolve my problem.
    May be that is you! Looking ahead to look you.

  2. Hi there! This is kind of off topic but I need some advice from an established blog. Is it tough to set up your own blog? I’m not very techincal but I can figure things out pretty quick. I’m thinking about creating my own but I’m not sure where to start. Do you have any tips or suggestions? Thanks

  3. I intended to compose you a tiny note to be able to say thanks a lot over again over the extraordinary information you’ve provided on this site. This has been tremendously generous of people like you to present unreservedly precisely what many individuals could possibly have distributed for an e-book to help with making some money for their own end, most importantly now that you might well have done it if you decided. The techniques in addition acted to provide a great way to be certain that the rest have the same dream just as my personal own to understand good deal more pertaining to this condition. I think there are several more fun occasions in the future for individuals that see your site.

  4. Can I simply say what a reduction to seek out somebody who truly knows what theyre talking about on the internet. You positively know how you can convey a problem to gentle and make it important. More individuals have to learn this and understand this facet of the story. I cant believe youre no more well-liked since you definitely have the gift.

  5. My programmer is trying to convince me to move to .net from PHP.
    I have always disliked the idea because of the costs.
    But he’s tryiong none the less. I’ve been using Movable-type on a
    variety of websites for about a year and am
    anxious about switching to another platform. I have heard great things
    about blogengine.net. Is there a way I can import
    all my wordpress posts into it? Any help would be really appreciated!

  6. Greetings! Quick question that’s completely off topic. Do you know how to make your site mobile friendly? My blog looks weird when viewing from my iphone4. I’m trying to find a theme or plugin that might be able to resolve this issue. If you have any suggestions, please share. Thank you!

  7. An impressive share, I just given this onto a colleague who was doing a little analysis on this. And he in fact bought me breakfast because I found it for him.. smile. So let me reword that: Thnx for the treat! But yeah Thnkx for spending the time to discuss this, I feel strongly about it and love reading more on this topic. If possible, as you become expertise, would you mind updating your blog with more details? It is highly helpful for me. Big thumb up for this blog post!

  8. Heya just wanted to give you a brief heads up and let you know a few of the images aren’t loading properly. I’m not sure why but I think its a linking issue. I’ve tried it in two different web browsers and both show the same results.

  9. Thanks for sharing excellent informations. Your site is very cool. I am impressed by the details that you¦ve on this web site. It reveals how nicely you perceive this subject. Bookmarked this website page, will come back for extra articles. You, my friend, ROCK! I found just the information I already searched all over the place and just could not come across. What a perfect site.

  10. I am really impressed with your writing skills as well as with the layout on your weblog.
    Is this a paid theme or did you modify it yourself?
    Anyway keep up the excellent quality writing, it’s rare
    to see a nice blog like this one today.

  11. Hey There. I discovered your weblog using msn. That is an extremely neatly written article.
    I’ll be sure to bookmark it and come back to read more of your helpful information. Thank you for the post.
    I’ll certainly return.

  12. I have read a few good stuff here. Definitely worth bookmarking for revisiting.
    I surprise how so much attempt you put to create this kind of magnificent informative site.

  13. Please let me know if you’re looking for a article author for your site.

    You have some really good articles and I think I would be a
    good asset. If you ever want to take some of the load off,
    I’d really like to write some material for your blog in exchange
    for a link back to mine. Please blast me an email if interested.
    Many thanks!

  14. Appreciating the hard work you put into your site and in depth information you offer. It’s nice to come across a blog every once in a while that isn’t the same unwanted rehashed material. Fantastic read! I’ve saved your site and I’m including your RSS feeds to my Google account.

  15. hi!,I love your writing so a lot! proportion we be in contact more approximately your post on AOL? I need an expert on this space to solve my problem. May be that is you! Looking forward to see you.

  16. Hiya, I’m really glad I’ve found this info. Today bloggers publish just about gossips and net and this is really frustrating. A good web site with exciting content, that’s what I need. Thank you for keeping this site, I’ll be visiting it. Do you do newsletters? Cant find it.

  17. Great info and right to the point. I am not sure if this is actually the best place to ask but do you guys have any ideea where to employ some professional writers? Thank you 🙂

  18. Valuable information. Lucky me I found your website by accident, and I am shocked why this accident didn’t happened earlier! I bookmarked it.

  19. Today, I went to the beach with my kids. I found a sea shell and gave it to my 4 year old daughter and said “You can hear the ocean if you put this to your ear.” She put the shell to her ear and screamed. There was a hermit crab inside and it pinched her ear. She never wants to go back! LoL I know this is entirely off topic but I had to tell someone!

  20. There are some attention-grabbing points in time on this article however I don’t know if I see all of them middle to heart. There is some validity however I will take maintain opinion till I look into it further. Good article , thanks and we would like more! Added to FeedBurner as effectively

  21. Wonderful site you have here but I was wanting to know if you knew of any forums
    that cover the same topics discussed in this article?
    I’d really like to be a part of online community where I can get feedback from other experienced individuals that share the same interest.
    If you have any recommendations, please let me know.

    Thanks!

  22. It’s a pity you don’t have a donate button! I’d definitely donate to this fantastic blog! I guess for now i’ll settle for book-marking and adding your RSS feed to my Google account. I look forward to fresh updates and will share this site with my Facebook group. Talk soon!

  23. I was wondering if you ever thought of changing the page layout of your site?
    Its very well written; I love what youve got to say.
    But maybe you could a little more in the way of content so people could connect with it better.

    Youve got an awful lot of text for only having one
    or two pictures. Maybe you could space it out better?

  24. Hello, Neat post. There’s an issue with your website in web explorer, could check thisK IE nonetheless is the marketplace chief and a big part of people will leave out your excellent writing due to this problem.

  25. Very well written article. It will be useful to anybody who usess it, including yours truly :). Keep up the good work – can’r wait to read more posts.

  26. I am now not certain the place you’re getting your information, however good topic. I needs to spend some time learning much more or working out more. Thank you for magnificent info I used to be searching for this info for my mission.

  27. Hey there, I think your blog might be having browser compatibility issues.
    When I look at your blog site in Firefox, it looks fine but when opening in Internet
    Explorer, it has some overlapping. I just wanted to give you
    a quick heads up! Other then that, wonderful blog!

  28. Restylane乃一系列用於美顏的長效透明質酸產品。 Restylane療程能有效撫平皺紋、美化臉型輪廓及唇部,並可改善膚質及肌膚的彈性。Restylane透明質酸作用原理 Restylane透明質酸均以非動物來源的透明質酸作為原料,獨有的NASHA™專利技術研製而成。微量Restylane透明質酸凝膠到皮膚中,可以讓您的面部肌膚恢復豐盈飽滿。 Restylane透明質酸中的透明質酸與人體內的天然透明質酸十分相似,使用前無需進行皮膚測試,引起過敏反應的機率亦極低。

  29. A formidable share, I just given this onto a colleague who was doing a little analysis on this. And he the truth is bought me breakfast as a result of I discovered it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I feel strongly about it and love reading extra on this topic. If doable, as you develop into experience, would you thoughts updating your weblog with extra details? It is highly helpful for me. Big thumb up for this weblog post!

  30. Wonderful web site. Plenty of useful information here. I am sending it to several friends ans additionally sharing in delicious. And obviously, thanks in your sweat!

  31. Good – I should definitely pronounce, impressed with your web site. I had no trouble navigating through all tabs and related info ended up being truly simple to do to access. I recently found what I hoped for before you know it at all. Reasonably unusual. Is likely to appreciate it for those who add forums or anything, website theme . a tones way for your client to communicate. Nice task.

  32. It’s the best time to make some plans for the longer term and it’s time to be happy. I’ve read this publish and if I could I want to suggest you some interesting issues or advice. Perhaps you can write subsequent articles relating to this article. I wish to read even more issues approximately it!

  33. Really superb information can be found on weblog. “The only thing you take with you when you’re gone is what you leave behind.” by John Allston.

  34. Thank you for some other wonderful post. The place else may just anybody get that type of information in such an ideal method of writing? I have a presentation subsequent week, and I’m at the search for such info.

  35. Thanks, I have recently been searching for info approximately this topic for a long time and yours is the greatest I’ve found out till now. However, what concerning the bottom line? Are you certain in regards to the source?

  36. I have been surfing online more than three hours lately, yet I never found any fascinating article like yours. It’s beautiful price enough for me. Personally, if all webmasters and bloggers made excellent content as you did, the net shall be a lot more helpful than ever before. “Dignity is not negotiable. Dignity is the honor of the family.” by Vartan Gregorian.

BİR CEVAP BIRAK

Lütfen yorumunuzu giriniz
Buraya isminizi giriniz