Ana sayfa Genel Python – Fonksiyonlarda Return

Python – Fonksiyonlarda Return


Fonksiyonlarda Return

Bu konuda fonksiyonlardan değer döndürmemizi sağlayan return ifadesini görmeye çalışacağız. Önceki bölümde yazdığımız fonksiyonları hatırlayacak olursak, bu fonksiyonlar sadece ekrana print ile değer yazdırıyordu. Ancak bu fonksiyonlar yaptıklar işlemler bize herhangi bir değer vermiyorlardı. Ancak biz programlarımızda bir fonksiyon sonucunda elde edilen değerleri alıp programlarımızın bambaşka yerlerinde kullanmak isteyebiliriz. Bu derste bunu nasıl yapacağımızı öğrenmeye çalışacağız.

return ifadesi fonksiyonun işlemi bittikten sonra çağrıldığı yere değer döndürmesi anlamı taşır. Böylelikle, fonksiyonda aldığımız değeri bir değişkende depolayabilir ve değeri programın başka yerlerinde kullanabiliriz. Şimdi iki tane çok basit fonksiyon yazalım ve return neden gereklidir anlamaya çalışalım.

Burada hata almamızın sebebi fonksiyonları herhangi bir değer döndürmemesi yani return kullanmamasıdır. İsterseniz toplam değişkeninin tipine bakalım.

Burada toplama fonksiyonundan herhangi bir değer döndürülmediği için toplam değişkenimiz hiçbir değere sahip olmadı ve tipi NoneType(atanmamış) olmuş oldu. İsterseniz burada fonksiyonları tekrardan tanımlayalım ve return mantığını anlamaya çalışalım.

İşte return ifadesinin anlamı tam olarak budur. return yardımıyla fonksiyonlar değerleri çağrıldığı yere döndürebilir ve biz de bu değerleri istediğimiz yerde kullanabiliriz.

Örneğin , siz yemek yapacaksınız ve yemek için soğanların kıyılması gerekiyor. Bunun için soğanları(değerleri),mutfak robotuna(fonksiyon) veriyorsunuz ve mutfak robotu kıyma işlemini gerçekleştiriyor. Ancak işlemlerini bitirdikten sonra mutfak robotu (ütopik bir örnek olsun) size soğanların kıyılmış halini vermiyor(returnkullanmıyor). Sonuçta da siz bu kıyılmış soğanları alıp yemeğinizde kullanamıyorsunuz. Fonksiyonlarda da returnun anlamı budur. Şimdi bir tane daha örnek yapalım ve returnu iyice anlamaya çalışalım.

return ifadesinden sonra fonksiyonumuz tamamıyla sona erer. Yani, return ifadesinden sonra yapılan herhangi bir işlem çalıştırılmaz.

Fonksiyonlarda çağrıldığı yere herhangi bir değer döndürmeyen(return kullanılmayan) fonksiyonlara void fonksiyonlar denmektedir. Bunu da genel kültür olarak bilmekte fayda var.

Bir sonraki konuda Fonksiyonlarda Parametre Türlerini öğrenmeye çalışacağız.


  1. What i don’t realize is actually how you are no longer really
    much more neatly-preferred than you might be right now.

    You’re so intelligent. You realize therefore significantly in terms of this subject, produced
    me in my view believe it from a lot of numerous angles.

    Its like men and women are not fascinated until it is something to accomplish with Woman gaga!
    Your own stuffs outstanding. Always handle
    it up!

  2. Hi, just required you to know I he added your site to my Google bookmarks due to your layout. But seriously, I believe your internet site has 1 in the freshest theme I??ve came across. It extremely helps make reading your blog significantly easier.

  3. I like what you guys are up too. Such smart work and reporting! Keep up the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my website 🙂

  4. Thanks for all of your efforts on this web page. Betty enjoys doing internet research and it’s obvious why. We all notice all regarding the lively method you deliver reliable steps via this web site and therefore foster response from the others on that idea plus our favorite daughter has been becoming educated a great deal. Enjoy the remaining portion of the year. You have been performing a good job.

  5. I believe this is among the most vital information for me. And i am satisfied studying your article. However wanna remark on few normal things, The web site taste is wonderful, the articles is in point of fact nice : D. Just right task, cheers

  6. It is perfect time to make a few plans for the long run and it’s time to be happy. I have read this publish and if I could I desire to suggest you some fascinating issues or suggestions. Perhaps you could write subsequent articles regarding this article. I wish to learn more things approximately it!

  7. I’m now not certain the place you are getting your info, however good
    topic. I must spend some time studying more or working out more.
    Thank you for wonderful information I used to be on the lookout for this information for my mission.

  8. Thanks for one’s marvelous posting! I definitely enjoyed reading it, you might be a great author.I will remember to bookmark your blog and will often come back in the foreseeable future. I want to encourage you to definitely continue your great work, have a nice holiday weekend!

  9. I have been exploring for a little for any high quality articles or weblog posts in this kind of house . Exploring in Yahoo I ultimately stumbled upon this site. Reading this info So i’m happy to exhibit that I’ve an incredibly just right uncanny feeling I found out exactly what I needed. I such a lot certainly will make sure to do not overlook this web site and give it a glance on a relentless basis.

  10. Howdy would you mind stating which blog platform you’re working with? I’m going to start my own blog soon but I’m having a hard time deciding between BlogEngine/Wordpress/B2evolution and Drupal. The reason I ask is because your design seems different then most blogs and I’m looking for something completely unique. P.S Sorry for being off-topic but I had to ask!

  11. I wish to express my appreciation to this writer just for rescuing me from this particular challenge. Just after scouting throughout the the net and seeing views which are not beneficial, I thought my entire life was done. Living without the presence of approaches to the difficulties you’ve resolved by way of the article content is a serious case, and ones that would have in a wrong way damaged my entire career if I hadn’t noticed your site. Your main knowledge and kindness in playing with a lot of stuff was crucial. I’m not sure what I would’ve done if I had not discovered such a thing like this. It’s possible to now relish my future. Thanks so much for the expert and effective guide. I will not think twice to refer your web sites to anyone who would like direction about this subject.

  12. We stumbled over here different website and thought I should check things out. I like what I see so now i am following you. Look forward to looking over your web page repeatedly.

  13. F*ckin’ awesome issues here. I am very glad to peer your post. Thank you so much and i’m having a look forward to contact you. Will you kindly drop me a e-mail?

  14. You actually make it seem so easy with your presentation but I find this topic to be actually something that I think I would never understand. It seems too complicated and extremely broad for me. I am looking forward for your next post, I’ll try to get the hang of it!

  15. Heya i’m for the primary time here. I came across this board and I in finding It really useful & it helped me out much. I hope to provide one thing back and aid others like you helped me.

  16. I have read several just right stuff here. Certainly price bookmarking for revisiting. I surprise how a lot attempt you set to make this kind of magnificent informative web site.

  17. Hey! I’m at work surfing around your blog from my new iphone 4! Just wanted to say I love reading your blog and look forward to all your posts! Carry on the fantastic work!

  18. I know this if off topic but I’m looking into starting my own blog and was curious what all is required to get setup? I’m assuming having a blog like yours would cost a pretty penny? I’m not very internet smart so I’m not 100 positive. Any suggestions or advice would be greatly appreciated. Many thanks

  19. Thanks for any other informative web site. The place else may just I am getting that kind of information written in such a perfect approach? I’ve a project that I am just now working on, and I’ve been at the glance out for such information.

  20. It’s actually a cool and helpful piece of information. I’m satisfied that you shared this helpful information with us. Please keep us up to date like this. Thank you for sharing.

  21. Wow! This could be one particular of the most useful blogs We’ve ever arrive across on this subject. Basically Wonderful. I’m also a specialist in this topic so I can understand your hard work.

  22. I like what you guys are up also. Such clever work and reporting! Carry on the superb works guys I have incorporated you guys to my blogroll. I think it’ll improve the value of my website :).

  23. Hiya very nice web site!! Man .. Beautiful .. Amazing .. I will bookmark your website and take the feeds additionally…I’m happy to search out a lot of helpful information right here within the submit, we’d like work out extra strategies in this regard, thanks for sharing. . . . . .

  24. hello!,I like your writing so a lot! proportion we communicate extra approximately your article on AOL? I require an expert on this space to unravel my problem. Maybe that is you! Looking ahead to peer you.

  25. I will right away snatch your rss as I can’t to find your email subscription hyperlink or e-newsletter service. Do you’ve any? Please allow me recognize in order that I could subscribe. Thanks.

  26. Hello there, simply become alert to your weblog thru Google, and found that it’s really informative. I am going to be careful for brussels. I’ll appreciate when you continue this in future. Lots of people shall be benefited from your writing. Cheers!

  27. 由全球生長因子與胜肽韓國廠商CAREGEN研發,利用美國專利「KP7-4胜肽技術」,獨特滲透配方提供高穩定、高滲透、高效能的胜髮環境,模擬人體生髮機制,目的使頭皮、毛囊恢復健康及作用活性,重啟生髮系統。DR CYJ髮胜肽療程的治療原理為 利用複合活性成分配方恢復毛髮平衡, 根據生態生物工程原理研發, 關鍵胜肽名為KP7-4,結合了七種專利胜肽, 實驗證明能有效模擬「人體胜髮因子」,掌握育髮四關鍵:毛囊強健、減緩異常落髮、強化髮根、供給毛囊血管營養,模擬毛髮循環機制,同時減緩異常落髮及強化髮根。DR.CYJ髮胜肽不含藥性且無副作用,能有效促進增髮

  28. Greetings from Idaho! I’m bored to death at work so I decided to check out your blog on my iphone during lunch break. I love the information you present here and can’t wait to take a look when I get home. I’m amazed at how fast your blog loaded on my phone .. I’m not even using WIFI, just 3G .. Anyhow, fantastic site!

  29. Can I just say what a reduction to seek out somebody who really is aware of what theyre talking about on the internet. You undoubtedly know how one can carry a problem to light and make it important. More people must read this and understand this facet of the story. I cant consider youre no more common because you positively have the gift.

  30. Hi, i think that i saw you visited my weblog thus i came to “return the favor”.I am trying to find things to improve my web site!I suppose its ok to use a few of your ideas!!

  31. When I originally commented I clicked the “Notify me when new comments are added” checkbox and now each time a comment is added I get three e-mails with the same comment. Is there any way you can remove me from that service? Many thanks!

  32. Thanks a lot for providing individuals with a very memorable possiblity to read articles and blog posts from this website. It’s usually so excellent plus jam-packed with a great time for me personally and my office co-workers to visit the blog at the least 3 times per week to learn the fresh things you have. And of course, we are certainly impressed considering the wonderful suggestions you give. Selected 4 points in this posting are rather the most efficient we have had.

  33. What i don’t understood is if truth be told how you’re not really much more well-preferred than you may be right now.
    You are so intelligent. You understand thus significantly when it comes to this topic, made me
    for my part believe it from numerous various angles. Its like men and women aren’t involved except it is one thing
    to accomplish with Woman gaga! Your individual stuffs outstanding.
    Always care for it up!

  34. I am really impressed with your writing skills as well as with the layout on your blog. Is this a paid theme or did you customize it yourself? Anyway keep up the excellent quality writing, it is rare to see a great blog like this one nowadays..

  35. I just couldn’t go away your web site prior to suggesting that I actually enjoyed the standard info an individual supply for your visitors? Is going to be again frequently to inspect new posts.

  36. Hi there, simply turned into aware of your blog via Google, and found that it’s truly informative. I’m gonna be careful for brussels. I will be grateful when you proceed this in future. Numerous other people will probably be benefited out of your writing. Cheers!

  37. It’s appropriate time to make some plans for the longer term and it’s time to be happy. I have read this post and if I could I wish to suggest you some fascinating things or advice. Perhaps you could write next articles regarding this article. I want to learn more things about it!

  38. This design is steller! You definitely know how to keep a reader amused. Between your wit and your videos, I was almost moved to start my own blog (well, almost…HaHa!) Excellent job. I really enjoyed what you had to say, and more than that, how you presented it. Too cool!


Lütfen yorumunuzu giriniz
Buraya isminizi giriniz