SlideShare a Scribd company logo
Demetler (Tuplelar)
Demetler veya İngilizce ismiyle tuplelar listelere oldukça benzer ancak farkları demetlerin değiştirilemez
oluşudur. Bu yüzden programlarımızda değiştirilmesini istemediğimiz değerleri bir demet içinde depolayabiliriz.
İsterseniz konumuza demetlerin oluşturulmasıyla başlayalım.
Demet Oluşturma
In [1]:
In [2]:
In [3]:
Peki tek elemanlı bir demet nasıl tanımlanır ?
In [4]:
In [5]:
In [6]:
Out[2]:
(1, 2, 3, 4, 5, 6, 7, 8, 9)
Out[3]:
tuple
Out[5]:
(1,)
Out[6]:
tuple
# Demet elemanları parantez içine alınarak demet oluşturulabilir.
demet = (1,2,3,4,5,6,7,8,9)
demet
# type() fonksiyonu yardımıyla türünü öğrenelim.
type(demet)
# Tek elemanlı demet bu şekilde tanımlanabilir.
demet = (1,)
demet
type(demet)
In [7]:
In [8]:
In [9]:
In [10]:
Demetlerin Temel Metodları
index metoduyla içine verdiğimiz elemanın hangi indekste olduğunu bulabiliriz.
In [11]:
In [12]:
count metoduyla içine verdiğimiz değerin demette kaç defa geçtiğini bulabiliriz.
Out[7]:
1
Out[8]:
5
Out[9]:
7
Out[10]:
(3, 4, 5, 6, 7)
Out[11]:
3
Out[12]:
0
demet = (1,2,3,4,5,6,7)
# 0. indekse ulaşma
demet[0]
# 4. indekse ulaşma
demet[4]
demet[-1]
demet[2:]
# Demeti oluşturalım.
demet = (1,2,3,"Mustafa","Murat","Coşkun")
# "Mustafa" elemanının indeksini buluyoruz.
demet.index("Mustafa")
demet.index(1)
In [17]:
In [18]:
Değiştirilmeme Özelliği
Demetlerin değiştirilemez olduğunu artık biliyoruz. İsterseniz bir deneme yapalım.
In [19]:
In [20]:
Demetleri Ne Zaman Kullanalım ?
Aslında Python programcıları demetlerden ziyade listeleri daha çok kullanır. Ancak eğer programınızda
değiştirilmesini istemediğiniz bilgiler varsa (Android uygulama sabitleri gibi) bunları demet içinde
depolayabilirsiniz. Aynı zamanda, Read Only(Sadece Okuma) bir veritipi olduğu için listelere göre biraz daha
hızlı çalışırlar.
Out[17]:
4
Out[18]:
3
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-19-b5e8086e73d6> in <module>()
2
3 demet = ("Elma","Armut","Muz")
----> 4 demet[0] = "Kiraz"
TypeError: 'tuple' object does not support item assignment
---------------------------------------------------------------------------
AttributeError Traceback (most recent call last)
<ipython-input-20-d49dcfce475c> in <module>()
----> 1 demet.remove("Elma")
AttributeError: 'tuple' object has no attribute 'remove'
demet = (1,23,34,34,2,1,4,5,1,1,34)
demet.count(1)
demet.count(34)
# Demet oluşturalım.
demet = ("Elma","Armut","Muz")
demet[0] = "Kiraz"
demet.remove("Elma")
7. Demet Veri Tipleri (Tuplelar).pdf

More Related Content

Featured

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
Pixeldarts
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
ThinkNow
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
marketingartwork
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
Skeleton Technologies
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
Neil Kimberley
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
contently
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
Albert Qian
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
Kurio // The Social Media Age(ncy)
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
Search Engine Journal
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
SpeakerHub
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
Tessa Mero
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Lily Ray
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
Rajiv Jayarajah, MAppComm, ACC
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
Christy Abraham Joy
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
Vit Horky
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
MindGenius
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
RachelPearson36
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Applitools
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
GetSmarter
 

Featured (20)

Product Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage EngineeringsProduct Design Trends in 2024 | Teenage Engineerings
Product Design Trends in 2024 | Teenage Engineerings
 
How Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental HealthHow Race, Age and Gender Shape Attitudes Towards Mental Health
How Race, Age and Gender Shape Attitudes Towards Mental Health
 
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdfAI Trends in Creative Operations 2024 by Artwork Flow.pdf
AI Trends in Creative Operations 2024 by Artwork Flow.pdf
 
Skeleton Culture Code
Skeleton Culture CodeSkeleton Culture Code
Skeleton Culture Code
 
PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024PEPSICO Presentation to CAGNY Conference Feb 2024
PEPSICO Presentation to CAGNY Conference Feb 2024
 
Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)Content Methodology: A Best Practices Report (Webinar)
Content Methodology: A Best Practices Report (Webinar)
 
How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024How to Prepare For a Successful Job Search for 2024
How to Prepare For a Successful Job Search for 2024
 
Social Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie InsightsSocial Media Marketing Trends 2024 // The Global Indie Insights
Social Media Marketing Trends 2024 // The Global Indie Insights
 
Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024Trends In Paid Search: Navigating The Digital Landscape In 2024
Trends In Paid Search: Navigating The Digital Landscape In 2024
 
5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary5 Public speaking tips from TED - Visualized summary
5 Public speaking tips from TED - Visualized summary
 
ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd ChatGPT and the Future of Work - Clark Boyd
ChatGPT and the Future of Work - Clark Boyd
 
Getting into the tech field. what next
Getting into the tech field. what next Getting into the tech field. what next
Getting into the tech field. what next
 
Google's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search IntentGoogle's Just Not That Into You: Understanding Core Updates & Search Intent
Google's Just Not That Into You: Understanding Core Updates & Search Intent
 
How to have difficult conversations
How to have difficult conversations How to have difficult conversations
How to have difficult conversations
 
Introduction to Data Science
Introduction to Data ScienceIntroduction to Data Science
Introduction to Data Science
 
Time Management & Productivity - Best Practices
Time Management & Productivity -  Best PracticesTime Management & Productivity -  Best Practices
Time Management & Productivity - Best Practices
 
The six step guide to practical project management
The six step guide to practical project managementThe six step guide to practical project management
The six step guide to practical project management
 
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
Beginners Guide to TikTok for Search - Rachel Pearson - We are Tilt __ Bright...
 
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
Unlocking the Power of ChatGPT and AI in Testing - A Real-World Look, present...
 
12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work12 Ways to Increase Your Influence at Work
12 Ways to Increase Your Influence at Work
 

7. Demet Veri Tipleri (Tuplelar).pdf

  • 1. Demetler (Tuplelar) Demetler veya İngilizce ismiyle tuplelar listelere oldukça benzer ancak farkları demetlerin değiştirilemez oluşudur. Bu yüzden programlarımızda değiştirilmesini istemediğimiz değerleri bir demet içinde depolayabiliriz. İsterseniz konumuza demetlerin oluşturulmasıyla başlayalım. Demet Oluşturma In [1]: In [2]: In [3]: Peki tek elemanlı bir demet nasıl tanımlanır ? In [4]: In [5]: In [6]: Out[2]: (1, 2, 3, 4, 5, 6, 7, 8, 9) Out[3]: tuple Out[5]: (1,) Out[6]: tuple # Demet elemanları parantez içine alınarak demet oluşturulabilir. demet = (1,2,3,4,5,6,7,8,9) demet # type() fonksiyonu yardımıyla türünü öğrenelim. type(demet) # Tek elemanlı demet bu şekilde tanımlanabilir. demet = (1,) demet type(demet)
  • 2. In [7]: In [8]: In [9]: In [10]: Demetlerin Temel Metodları index metoduyla içine verdiğimiz elemanın hangi indekste olduğunu bulabiliriz. In [11]: In [12]: count metoduyla içine verdiğimiz değerin demette kaç defa geçtiğini bulabiliriz. Out[7]: 1 Out[8]: 5 Out[9]: 7 Out[10]: (3, 4, 5, 6, 7) Out[11]: 3 Out[12]: 0 demet = (1,2,3,4,5,6,7) # 0. indekse ulaşma demet[0] # 4. indekse ulaşma demet[4] demet[-1] demet[2:] # Demeti oluşturalım. demet = (1,2,3,"Mustafa","Murat","Coşkun") # "Mustafa" elemanının indeksini buluyoruz. demet.index("Mustafa") demet.index(1)
  • 3. In [17]: In [18]: Değiştirilmeme Özelliği Demetlerin değiştirilemez olduğunu artık biliyoruz. İsterseniz bir deneme yapalım. In [19]: In [20]: Demetleri Ne Zaman Kullanalım ? Aslında Python programcıları demetlerden ziyade listeleri daha çok kullanır. Ancak eğer programınızda değiştirilmesini istemediğiniz bilgiler varsa (Android uygulama sabitleri gibi) bunları demet içinde depolayabilirsiniz. Aynı zamanda, Read Only(Sadece Okuma) bir veritipi olduğu için listelere göre biraz daha hızlı çalışırlar. Out[17]: 4 Out[18]: 3 --------------------------------------------------------------------------- TypeError Traceback (most recent call last) <ipython-input-19-b5e8086e73d6> in <module>() 2 3 demet = ("Elma","Armut","Muz") ----> 4 demet[0] = "Kiraz" TypeError: 'tuple' object does not support item assignment --------------------------------------------------------------------------- AttributeError Traceback (most recent call last) <ipython-input-20-d49dcfce475c> in <module>() ----> 1 demet.remove("Elma") AttributeError: 'tuple' object has no attribute 'remove' demet = (1,23,34,34,2,1,4,5,1,1,34) demet.count(1) demet.count(34) # Demet oluşturalım. demet = ("Elma","Armut","Muz") demet[0] = "Kiraz" demet.remove("Elma")