Ana sayfa Programlama Pythondaki Sayı Veri Tipleri

Pythondaki Sayı Veri Tipleri

4094
84
PAYLAŞ

Herkese Merhaba. Bu yazımızda Pythondaki sayı veritiplerini öğreneceğiz.

Bu yazıda şunları öğreneceğiz.

  • Tamsayı( Integer ) ve Ondalıklı Sayı(Float )
  • Basit Matematik İşlemleri
  • Değişken Tanımlama

Tamsayılar(Integer)

Matematikte gördüğümüz tüm sayılar (negatif,pozitif) aslında Python’da bir veri tipidir. Tamsayılar ise ingilizce olarak Integer olarak geçmektedir.

Örnek olarak, -1000,34,2,0 gibi sayılar Python’da birer tamsayı(integer) değerleridir.

Ondalıklı Sayı(Float)

Tamsayılar gibi Ondalıklı sayılar da bizim matematikte gördüğümüz sayı çeşitlerinden bir tanesidir. Ondalıklı sayılar matematikte olduğu gibi, Pythonda da bir veri tipidir.Ondalıklı Sayılar veya diğer adıyla Kayan Sayılar İngilizce olarak Float olarak geçmektedir.

Örnek olarak, 3.14, 3.554546, -13.54 gibi sayılar Python’da birer ondalıklı sayı(float) değerleridir.

Şimdi de bu Pythondaki basit matematik işlemlerini öğrenelim.

Basit Matematik Operatörleri

Çıktı: 7

Çıktı: -12

Çıktı: 52

Çıktı: 2.0

Burada basit işlemlerimizi görmüş olduk. Ancak son işlem kafanızı karıştırmış olabilir. Sonuç neden float bir değer olarak karşımıza çıktı? Bunları Matematik Operatörleri bölümünde görmek daha doğru olur diye düşünüyorum.

Bu basit işlemleri gördüğümüze göre, şimdi de Pythondaki değişken tanımlama işlemlerimizi öğrenmeye çalışalım.

Değişkenler ve Değişken Tanımlama

Değişkenler bir programlama dilinde olmazsa olmaz bir kavramdır. Değişkenler aslında bir veri tipinden değer tutan birimlerdir.İsterseniz şimdi de Pythonda bir tane değişken oluşturalım.

Güzel! Değişkenimizi oluşturduk. Şimdi değişkenin değerini ekrana bastıralım.


Çıktı: 10

Ekrana bastırdığımızda değişkenimizin değeri 10 olarak karşımıza çıktı.Peki şu işlemi yaparsak ne olacak ?


Çıktı: 1000

Sonuç, değişkenimizin değerinin 3.kuvveti şeklinde karşımıza çıkmış oldu. Şimdi de değişkenimizin değerini değiştirelim. Bunun için , yeni değerimizi “=”operatörüyle değişkenimize atamamız gerekiyor.


Çıktı : 15

Şimdi de 3 tane farklı değişken oluşturmaya çalışalım.

Peki burada “c” değişkeninin değeri ne olacak ? Bu işlemde ilk olarak = operatörünün sağ taraftaki işlemi hesaplanıyor ve sonra c değişkenine hesaplanan değer atanıyor.

Çıktı : 10

İşte bu kadar basit ! Son olarak değişkenlerimize isim verirken dikkat etmemiz gereken noktalardan bahsedelim.

  1. Değişken isimleri bir sayı ile başlayamaz.
  2. Değişken ismi kelimelerden oluşuyorsa aralarında boşluk olamaz.
  3. :'”,<>/?|\()!@#$%^&*~-+ Buradaki semboller değişken ismi içinde kullanılamaz.(Sadece _ sembolü kullanılabilir)
  4. Pythonda tanımlı anahtar kelimeler değişken ismi olarak kullanılamaz.(while, not vs. )

Hata Çıktısı:

Son olarak öğrendiklerimizle ilgili bir kaç işlem yapalım. Sonuçlara bakmadan işlemlerin sonucunu tahmin etmeye çalışın.

Çıktı : 12.56

Python’da iki değişkenin değerini birbiriyle değiştirmek için pratik bir yöntem bulunmaktadır.

Çıktı :
3
4

Son olarak bir değişkenin değerini artırma işlemlerinde Pythonda pratik bir yöntem bulunmaktadır. Aşağıdaki koda bakalım.

Çıktı : 6

Buradaki “a = a + 1” işlemini Pythonda “a += 1” şeklinde yazabiliriz.


Çıktı: 11

Çıktı : 3

Çıktı : 30

Yorum Satırları

Yorum satırları programlarımıza açıklama olarak eklediğimiz satırlardır. Eğer bir programda yorum satırları kullanılmışsa bu satırlar Python tarafından görülmez ve çalıştırılmaz.

İşte bu kadar! Bir sonraki yazıda görüşmek üzere!

Mustafa Murat Coşkun

PAYLAŞ
Sonraki makalePythonda Operatörler
Odtü Bilgisayar Mühendisliğinden 2017 senesinde mezun oldum ve şu anda aktif olarak eğitmenlik yapıyorum. Ayrıca şu anda Odtü Bilgisayar Mühendisliği Yüksek Lisansta akademik hayatımı sürdürüyorum.

84 YORUMLAR

  1. I really love your blog.. Very nice colors & theme.
    Did you make this website yourself? Please reply back as I’m wanting to create my very own blog and want to
    know where you got this from or just what the theme
    is named. Kudos!

  2. hello!,I really like your writing so a lot! percentage we keep up a correspondence more approximately your post on AOL? I need a specialist in this house to solve my problem. May be that’s you! Looking ahead to look you.

  3. Hey There. I found your blog using msn. This is a really well written article. I’ll be sure to bookmark it and come back to read more of your useful information. Thanks for the post. I will certainly return.

  4. Hey there just wanted to give you a quick heads up. The words in your article seem to be running off the screen in Firefox. I’m not sure if this is a format issue or something to do with internet browser compatibility but I figured I’d post to let you know. The design look great though! Hope you get the issue fixed soon. Many thanks

  5. Magnificent items from you, man. I’ve have in mind your stuff prior
    to and you’re just extremely fantastic. I really like what you’ve got right here, certainly like what you are saying and the way in which you are
    saying it. You are making it entertaining and
    you still take care of to stay it sensible. I can’t wait to
    learn far more from you. That is actually a wonderful website.

  6. It’s appropriate time to make some plans for the future and it is time to be happy. I’ve read this post and if I could I want to suggest you some interesting things or suggestions. Maybe you can write next articles referring to this article. I desire to read even more things about it!

  7. Hi this is somewhat of off topic but I was wanting to know if blogs use WYSIWYG editors or if you have to manually code with HTML. I’m starting a blog soon but have no coding knowledge so I wanted to get guidance from someone with experience. Any help would be greatly appreciated!

  8. you are in point of fact a excellent webmaster. The website loading pace is amazing. It sort of feels that you are doing any unique trick. In addition, The contents are masterpiece. you’ve done a excellent activity in this matter!

  9. Unquestionably believe that which you said.
    Your favorite reason seemed to be on the internet the
    easiest thing to be aware of. I say to you, I certainly get annoyed while people
    think about worries that they plainly don’t know about.
    You managed to hit the nail upon the top and also defined out the whole thing without having side-effects ,
    people could take a signal. Will likely be
    back to get more. Thanks

  10. Hi there, I found your site via Google while searching for a related topic, your site came up, it looks good. I have bookmarked it in my google bookmarks.

  11. My brother suggested I would possibly like this web site. He used to be entirely right. This post actually made my day. You can not imagine just how so much time I had spent for this info! Thank you!

  12. I used to be more than happy to search out this internet-site.I wished to thanks for your time for this glorious read!! I positively enjoying each little bit of it and I have you bookmarked to check out new stuff you blog post.

  13. May I simply say what a comfort to uncover someone that truly
    knows what they are talking about on the web. You definitely understand how to bring an issue to light
    and make it important. More people need to check this out and understand this side of the story.
    It’s surprising you are not more popular because you certainly possess the gift.

  14. Great blog you have here but I was curious if you knew of any community forums that cover the same topics talked about in this article? I’d really love to be a part of group where I can get feed-back from other knowledgeable individuals that share the same interest. If you have any recommendations, please let me know. Thanks a lot!

  15. Thank you, I have just been searching for info about this subject for a while and yours is the best I’ve found out so far. However, what in regards to the conclusion? Are you positive about the source?

  16. Have you ever considered publishing an e-book or guest authoring on other blogs? I have a blog centered on the same ideas you discuss and would love to have you share some stories/information. I know my audience would appreciate your work. If you are even remotely interested, feel free to send me an e mail.

  17. Sling tv coupons and promo codes for november 2018
    Great goods from you, man. I have understand your stuff previous to and you are just too wonderful.
    I really like what you have acquired here, certainly like what you are saying and the
    way in which you say it. You make it enjoyable
    and you still care for to keep it sensible. I can’t wait to read much more from you.
    This is really a terrific website. Sling tv coupons and promo codes for november 2018

  18. Hello my loved one! I want to say that this article is amazing, great written and come with approximately all important infos. I would like to look extra posts like this .

  19. Hiya! Quick question that’s totally off topic.
    Do you know how to make your site mobile friendly?

    My blog looks weird when browsing from my iphone4. I’m trying
    to find a theme or plugin that might be able to correct this issue.
    If you have any suggestions, please share. With thanks!

  20. We are a group of volunteers and starting a new scheme in our community. Your site offered us with valuable information to work on. You’ve done an impressive job and our whole community will be grateful to you.

  21. After study a few of the blog posts on your website now, and I truly like your way of blogging. I bookmarked it to my bookmark website list and will be checking back soon. Pls check out my web site as well and let me know what you think.

  22. Wow! This can be one particular of the most helpful blogs We’ve ever arrive across on this subject. Basically Great. I am also a specialist in this topic so I can understand your hard work.

  23. Does your blog have a contact page? I’m having a tough time locating it but, I’d like to shoot you an e-mail. I’ve got some recommendations for your blog you might be interested in hearing. Either way, great site and I look forward to seeing it grow over time.

  24. 高能聚焦量超聲波( HIFU )以物理性聚焦集中成一點, 快速穿透皮膚真皮及脂肪層面直達面部表淺肌肉腱膜系統( SMAS )層令其組織細胞分子高速磨擦 , 瞬間升溫至60 -70 度,令整個表淺肌肉腱膜系統( SMAS )受熱收縮,形成熱固化區域, 令結綈組織同時拉緊,達到拉皮防皺及美容效果。SMAZ聚焦超聲波提供了最有效的HIFU能量收緊皮膚及刺激胶原蛋白新生,提升彈性,恢復更緊緻的皮膚和更年輕的美貌。

  25. Hi there! I just wanted to ask if you ever have any trouble with hackers? My last blog (wordpress) was hacked and I ended up losing many months of hard work due to no back up. Do you have any methods to stop hackers?

  26. Hmm is anyone else encountering problems with the images on this blog loading? I’m trying to determine if its a problem on my end or if it’s the blog. Any suggestions would be greatly appreciated.

  27. Hi there, There’s no doubt that your web site could possibly
    be having browser compatibility issues. Whenever I look at your website in Safari,
    it looks fine but when opening in IE, it has some overlapping issues.
    I simply wanted to give you a quick heads up! Besides that,
    great website!

  28. Can I just say what a relief to find someone who actually knows what theyre talking about on the internet. You definitely know how to bring an issue to light and make it important. More people need to read this and understand this side of the story. I cant believe youre not more popular because you definitely have the gift.

  29. I love your blog.. very nice colors & theme. Did you design this website yourself or did you hire someone to do it for you? Plz respond as I’m looking to create my own blog and would like to find out where u got this from. many thanks

  30. This is the right blog for anyone who wants to find out about this topic. You realize so much its almost hard to argue with you (not that I actually would want…HaHa). You definitely put a new spin on a topic thats been written about for years. Great stuff, just great!

BİR CEVAP BIRAK

Lütfen yorumunuzu giriniz
Buraya isminizi giriniz