SlideShare une entreprise Scribd logo
Python’a Giriş
Tayyip Gören
Maltepe Üniversitesi
13 Kasım, 2019
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 1 / 27
Section 1
Giriş
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 2 / 27
Ben kimim? - whoami
An itibariyle üniversitemizde 4.sınıf öğrencisiyim. Aynı zamanda Ramtek
Telekom şirketinde Developer olarak çalışmaktayım. Şu ana kadar çalıştığım
projelerde çoğu yerde Python kullandım. Üniversite 1.Sınıftan beri Python
kullanmaktayım.
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 3 / 27
Python nedir, ne işe yarar?
Python is an interpreted, high-level, general-purpose programming language.
Created by Guido van Rossum and first released in 1991, Python’s design
philosophy emphasizes code readability with its notable use of significant
whitespace. Its language constructs and object-oriented approach aim to
help programmers write clear, logical code for small and large-scale projects
Python yorumlanan, üst seviye, genel amaçlı bir programlama dilidir. Guido
van Rossum tarafından oluşturulup, 1991 de ilk kullanıma sunulmuştur.
Python’nın tasarım mantalitesi bol miktarda boşluk kullanarak kod
okunabilirliğini arttırmak üzerinedir. Dil küçük ve büyük boyutlu projelerde,
temiz ve nesne yönelimli kod yazmaya yardımcı olur.
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 4 / 27
Nerelerde kullanabilirim?
Figure 1: Python’nın kullanım alanlarıTayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 5 / 27
Section 2
Öğrenelim
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 6 / 27
Python’ı yüklemek
Figure 2: python.org
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 7 / 27
Python Yüklemesini Doğrulamak
Windows sistemlerinde; cmd, Linux ve Maclerde; shell üzerinde komutunu
çalıştırın
python --version
Çıktısı : Python 3.7.4
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 8 / 27
Visual Studio Code
Figure 3: https://code.visualstudio.com/
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 9 / 27
Hello World
Bir yazılımcı selamı olan ‘Hello, World!’
print("Hello, World!")
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 10 / 27
Syntax
Reserved Words
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 11 / 27
Indentation
Python
if True:
print("True")
else:
print("False")
C
if (true){
printf("True");
}else {
printf("False");
}
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 12 / 27
Yanlış Indentation
Python
if True:
print("True")
else:
print("False")
C
if(true){
printf("True");
}else{
printf("False");
}
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 13 / 27
Yorumlar
Tek satır yorum
print("Hello, Python!") # comment
Çoklu satır yorum
’’’
Bu bir çoklu
Satır
Yorum
’’’
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 14 / 27
Section 3
Değişken Tipleri
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 15 / 27
Atama
counter = 100 # Tam sayı
miles = 1000.0 # Ondalıklı sayı
name = "Tayyip" # String (Yazı)
print(counter)
print(miles)
print(name)
Çıktısı
100
1000.0
Tayyip
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 16 / 27
Standart Veri Tipleri
Sayılar
String (Yazı)
List
Tuple
Dictionary
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 17 / 27
Sayılar
int (signed integers)
long (long integers, they can also be represented in octal and
hexadecimal)
float (floating point real values)
complex (complex numbers)
Örnekler
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 18 / 27
Stringler (Yazılar)
yazı = ’Hello World!’
print(yazı) # Yazıyı bastırır
print(yazı[0]) # Yazının ilk karakterini bastırır
print(yazı[2:5]) # 3’ten 5’inci karakterine kadar bastırır
print(yazı[2:]) # 2’inci karakterden sona kadar bastırır
print(yazı * 2) # Yazıyı iki kez bastırır
print(yazı + "TEST") # Yazı ile ’TEST’i birleştirip bastırır
Çıktısı
Hello World!
H
llo
llo World!
Hello World!Hello World!
Hello World!TEST
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 19 / 27
Listeler
listem = [ ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ]
küçük_listem = [123, ’tayyip’]
print(listem) # Listeyi tamamıyla bastırır
print(listem[0]) # Listenin ilk elemanını bastırır
print(listem[1:3]) # Listenin 1’den 3’e elemanlarını basar
print(listem[2:]) # Listeyi 2’den başlayarak basar
print(küçük_listem * 2) # Listeyi iki kere basar
print(listem + küçük_listem) # Listeleri birleştirip basar
Çıktısı
[’abcd’, 786, 2.23, ’tayyip’, 70.2]
abcd
[786, 2.23]
[2.23, ’tayyip’, 70.2]
[123, ’tayyip’, 123, ’tayyip’]
[’abcd’, 786, 2.23, ’tayyip’, 70.2, 123, ’tayyip’]
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 20 / 27
Tuple
Tuple’ın List’lerden farkı Tuple’ların elemanları değişemez. Listeler ‘[]’ ile
Tuplelar ‘()’ ile oluşturulur.
örnek_tuple = ( ’abcd’, 786 , 2.23, ’tayyip’, 70.2 )
küçük_tuple = (123, ’tayyip’)
print(örnek_tuple) # Tuple’ı tamamıyla bastırır
print(örnek_tuple[0]) # Tuple’ın ilk elemanını bastırır
print(örnek_tuple[1:3]) # Tuple’ın 1’den 3’e elemanlarını basa
print(örnek_tuple[2:]) # Tuple’ı 2’den başlayarak basar
print(küçük_tuple * 2) # Tuple’ı iki kere basar
print(örnek_tuple + küçük_tuple) # Tuple’ları birleştirip basa
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 21 / 27
Tuple Çıktı
(’abcd’, 786, 2.23, ’tayyip’, 70.2)
abcd
(786, 2.23)
(2.23, ’tayyip’, 70.2)
(123, ’tayyip’, 123, ’tayyip’)
(’abcd’, 786, 2.23, ’tayyip’, 70.2, 123, ’tayyip’)
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 22 / 27
Tuple ile List Farkı
örnek_tuple = ( ’abcd’, 786 , 2.23, ’tayyip’, 70.2 )
listem = [ ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ]
örnek_tuple[2] = 1000 # Yanlış syntax hata verir
listem[2] = 1000 # Doğru syntax
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 23 / 27
Dictionary
örnek_dict = {}
örnek_dict[’one’] = "This is one"
örnek_dict[2] = "This is two"
küçük_örnek_dict = {
’name’: ’john’,
’code’:6734,
’dept’: ’sales’
}
print(örnek_dict[’one’]) # ’one’ anahtarının verisini basar
print(örnek_dict[2]) # 2 anahtarı için veriyi basar
print(küçük_örnek_dict) # Bütün dictionary’i basar
print(küçük_örnek_dict.keys()) # Bütün anahtarları basar
print(küçük_örnek_dict.values()) # Bütün değerleri basar
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 24 / 27
Dictionary Çıktı
’This is one’
’This is two’
{’dept’: ’sales’, ’code’: 6734, ’name’: ’john’}
[’dept’, ’code’, ’name’]
[’sales’, 6734, ’john’]
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 25 / 27
Veri Tipi Değişimleri
int(veri)
long(veri)
float(veri)
str(veri)
tuple(veri)
list(veri)
dict(veri)
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 26 / 27
Section 4
Basit Operatörler
Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 27 / 27

Contenu connexe

En vedette

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
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
Alireza Esmikhani
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
Project for Public Spaces & National Center for Biking and Walking
 

En vedette (20)

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
 
ChatGPT webinar slides
ChatGPT webinar slidesChatGPT webinar slides
ChatGPT webinar slides
 
More than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike RoutesMore than Just Lines on a Map: Best Practices for U.S Bike Routes
More than Just Lines on a Map: Best Practices for U.S Bike Routes
 

Python'a Giriş

  • 1. Python’a Giriş Tayyip Gören Maltepe Üniversitesi 13 Kasım, 2019 Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 1 / 27
  • 2. Section 1 Giriş Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 2 / 27
  • 3. Ben kimim? - whoami An itibariyle üniversitemizde 4.sınıf öğrencisiyim. Aynı zamanda Ramtek Telekom şirketinde Developer olarak çalışmaktayım. Şu ana kadar çalıştığım projelerde çoğu yerde Python kullandım. Üniversite 1.Sınıftan beri Python kullanmaktayım. Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 3 / 27
  • 4. Python nedir, ne işe yarar? Python is an interpreted, high-level, general-purpose programming language. Created by Guido van Rossum and first released in 1991, Python’s design philosophy emphasizes code readability with its notable use of significant whitespace. Its language constructs and object-oriented approach aim to help programmers write clear, logical code for small and large-scale projects Python yorumlanan, üst seviye, genel amaçlı bir programlama dilidir. Guido van Rossum tarafından oluşturulup, 1991 de ilk kullanıma sunulmuştur. Python’nın tasarım mantalitesi bol miktarda boşluk kullanarak kod okunabilirliğini arttırmak üzerinedir. Dil küçük ve büyük boyutlu projelerde, temiz ve nesne yönelimli kod yazmaya yardımcı olur. Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 4 / 27
  • 5. Nerelerde kullanabilirim? Figure 1: Python’nın kullanım alanlarıTayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 5 / 27
  • 6. Section 2 Öğrenelim Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 6 / 27
  • 7. Python’ı yüklemek Figure 2: python.org Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 7 / 27
  • 8. Python Yüklemesini Doğrulamak Windows sistemlerinde; cmd, Linux ve Maclerde; shell üzerinde komutunu çalıştırın python --version Çıktısı : Python 3.7.4 Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 8 / 27
  • 9. Visual Studio Code Figure 3: https://code.visualstudio.com/ Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 9 / 27
  • 10. Hello World Bir yazılımcı selamı olan ‘Hello, World!’ print("Hello, World!") Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 10 / 27
  • 11. Syntax Reserved Words Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 11 / 27
  • 12. Indentation Python if True: print("True") else: print("False") C if (true){ printf("True"); }else { printf("False"); } Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 12 / 27
  • 14. Yorumlar Tek satır yorum print("Hello, Python!") # comment Çoklu satır yorum ’’’ Bu bir çoklu Satır Yorum ’’’ Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 14 / 27
  • 15. Section 3 Değişken Tipleri Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 15 / 27
  • 16. Atama counter = 100 # Tam sayı miles = 1000.0 # Ondalıklı sayı name = "Tayyip" # String (Yazı) print(counter) print(miles) print(name) Çıktısı 100 1000.0 Tayyip Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 16 / 27
  • 17. Standart Veri Tipleri Sayılar String (Yazı) List Tuple Dictionary Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 17 / 27
  • 18. Sayılar int (signed integers) long (long integers, they can also be represented in octal and hexadecimal) float (floating point real values) complex (complex numbers) Örnekler Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 18 / 27
  • 19. Stringler (Yazılar) yazı = ’Hello World!’ print(yazı) # Yazıyı bastırır print(yazı[0]) # Yazının ilk karakterini bastırır print(yazı[2:5]) # 3’ten 5’inci karakterine kadar bastırır print(yazı[2:]) # 2’inci karakterden sona kadar bastırır print(yazı * 2) # Yazıyı iki kez bastırır print(yazı + "TEST") # Yazı ile ’TEST’i birleştirip bastırır Çıktısı Hello World! H llo llo World! Hello World!Hello World! Hello World!TEST Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 19 / 27
  • 20. Listeler listem = [ ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ] küçük_listem = [123, ’tayyip’] print(listem) # Listeyi tamamıyla bastırır print(listem[0]) # Listenin ilk elemanını bastırır print(listem[1:3]) # Listenin 1’den 3’e elemanlarını basar print(listem[2:]) # Listeyi 2’den başlayarak basar print(küçük_listem * 2) # Listeyi iki kere basar print(listem + küçük_listem) # Listeleri birleştirip basar Çıktısı [’abcd’, 786, 2.23, ’tayyip’, 70.2] abcd [786, 2.23] [2.23, ’tayyip’, 70.2] [123, ’tayyip’, 123, ’tayyip’] [’abcd’, 786, 2.23, ’tayyip’, 70.2, 123, ’tayyip’] Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 20 / 27
  • 21. Tuple Tuple’ın List’lerden farkı Tuple’ların elemanları değişemez. Listeler ‘[]’ ile Tuplelar ‘()’ ile oluşturulur. örnek_tuple = ( ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ) küçük_tuple = (123, ’tayyip’) print(örnek_tuple) # Tuple’ı tamamıyla bastırır print(örnek_tuple[0]) # Tuple’ın ilk elemanını bastırır print(örnek_tuple[1:3]) # Tuple’ın 1’den 3’e elemanlarını basa print(örnek_tuple[2:]) # Tuple’ı 2’den başlayarak basar print(küçük_tuple * 2) # Tuple’ı iki kere basar print(örnek_tuple + küçük_tuple) # Tuple’ları birleştirip basa Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 21 / 27
  • 22. Tuple Çıktı (’abcd’, 786, 2.23, ’tayyip’, 70.2) abcd (786, 2.23) (2.23, ’tayyip’, 70.2) (123, ’tayyip’, 123, ’tayyip’) (’abcd’, 786, 2.23, ’tayyip’, 70.2, 123, ’tayyip’) Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 22 / 27
  • 23. Tuple ile List Farkı örnek_tuple = ( ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ) listem = [ ’abcd’, 786 , 2.23, ’tayyip’, 70.2 ] örnek_tuple[2] = 1000 # Yanlış syntax hata verir listem[2] = 1000 # Doğru syntax Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 23 / 27
  • 24. Dictionary örnek_dict = {} örnek_dict[’one’] = "This is one" örnek_dict[2] = "This is two" küçük_örnek_dict = { ’name’: ’john’, ’code’:6734, ’dept’: ’sales’ } print(örnek_dict[’one’]) # ’one’ anahtarının verisini basar print(örnek_dict[2]) # 2 anahtarı için veriyi basar print(küçük_örnek_dict) # Bütün dictionary’i basar print(küçük_örnek_dict.keys()) # Bütün anahtarları basar print(küçük_örnek_dict.values()) # Bütün değerleri basar Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 24 / 27
  • 25. Dictionary Çıktı ’This is one’ ’This is two’ {’dept’: ’sales’, ’code’: 6734, ’name’: ’john’} [’dept’, ’code’, ’name’] [’sales’, 6734, ’john’] Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 25 / 27
  • 26. Veri Tipi Değişimleri int(veri) long(veri) float(veri) str(veri) tuple(veri) list(veri) dict(veri) Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 26 / 27
  • 27. Section 4 Basit Operatörler Tayyip Gören (Maltepe Üniversitesi) Python’a Giriş 13 Kasım, 2019 27 / 27