Created
January 14, 2020 16:24
-
-
Save emreedemir/20de1ec1ccc9f93b03e03b4862e571b3 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from collections import deque | |
##Liste Veri Yapilari | |
liste=[2,4,6,8] | |
liste2 =[10,12,14,16] | |
liste.append(20)##listenin sonuna ekleme yapar | |
liste.extend(liste2) | |
print(liste) | |
liste.insert(0,-2)##sıfır indexli yere -2 ekle | |
liste.remove(-2) | |
liste.pop(0) ##0indexlii elamanı siler | |
liste2.clear() ##listenin butun elamanlarini siler | |
liste.index(10) ##10 degerinin indedx degerini veriri | |
liste.count(10) ##10 elamanını sayisini verir | |
liste3 =liste.copy() ##listeyi kopyalar | |
liste3.reverse() ##sıralar | |
liste3.sort() ##kucukten buyuge sıralar | |
##LİSTE URETEÇLERİ | |
newListe=[x for x in range(50)] | |
newListe2=[x**2 for x in range(50)] | |
newListe3=[x for x in range(50) if x %2 ==0] #0 dan 50 ye kadar çift sayilari | |
newListe3=[x for x in range(100) if x%2 !=0] | |
##soru 4 ile 12 arasında çif sayılari tutan liste | |
l=[] | |
for x in range(4,12): #4 ü alır 12 i almaz | |
if(x%2 ==0 ): | |
l.append(x) | |
print(l) | |
##Soru BEYKENT kelimesinde harfleri kucukten buyuge siralayan programi yazin | |
x =list("BEYKENT") | |
x.sort() | |
print(x) | |
##Soru BEYKENT kelimesindeki yeni bir diziye tersten ekletip ekrana yazdıran programı yazın | |
by =list("BEYKENT") | |
by.reverse() | |
tr =by | |
print(tr) | |
####STACK VERI Yapisi | |
#stack is lifo | |
##list i stack gibi kullanma | |
stackList=[1,2,3,4,5,] | |
stackList.append(6) #sona ekler | |
stackList.append(7) | |
print(stackList) | |
stackList.pop() #sondan cikarir | |
print(stackList) | |
#Dequeue | |
queueList =deque([1,2,3,4,5,6]) | |
queueList.append(6) | |
queueList.popleft() #1 kuyruktan cikar | |
queueList.popleft() #2 kuyruktan cikar | |
print(queueList) | |
print(list(queueList)) ##queue liste dönüstü | |
##TUPLE(Demet) veri yapisi | |
#Demetler dogrudan degistirilemeyen sirali,nesneler dizisidir. | |
tupleExample =('Y','A','Z','A','L','I','M') | |
emptyTuple=() | |
stringTuple =("Emre","Fazil","Zeynep") | |
listFromTuplle=list(stringTuple) | |
tupleFromList =tuple(listFromTuplle) | |
def convertTupleToString(tup): | |
str ="".join(tup) | |
return str | |
convertedTuple =("A","N","K","A") | |
strFromTuple =convertTupleToString(convertedTuple) | |
print(strFromTuple) | |
##Demet elemanlarına indis ile erişilebilir ama dogrudan erişilemez | |
citiesTuple =("Ankara","Rize","Sivas") | |
## Soru citiesTuple son elamnı "Ordu" ekle ve Rizeyi sil | |
citiesTuple =list(citiesTuple) ##eklemesi kolay olsun diye liste çevirdik | |
citiesTuple.append("Ordu") | |
citiesTuple.remove("Rize") | |
tuple(citiesTuple) | |
print(citiesTuple) | |
##List ve Tuple da arama | |
numberTuple =(1,2,3,51,12,53,9) | |
findedNumber =int(input("Enter finded number")) | |
if findedNumber in numberTuple : | |
indexof =numberTuple.index(findedNumber) | |
print("ARanan sayi ",indexof+1 ,". sirada bulundu") | |
else : | |
print("No number finded") | |
##Set(küme) veri yapisi | |
##Tekrarli eleman olmaz,kümenin elamanlari siralı olmak zorundadir | |
##küme elemanlarina ulaşmak için indis kullanılmaz | |
basicSet ={"T","A","M","A","M"} | |
emptySet =set() | |
aSet =set("KALABALIK") | |
aSet={'A','B','L','K','I'} | |
ASET ={1,2,3} | |
BSET={0,1,2} | |
CSET =ASET.difference(BSET) ##A nin B den farki | |
DSET =ASET.intersection(BSET) ##ortak elemanlar | |
ESET =ASET.union(BSET) ##birlesim | |
print(CSET) | |
print(DSET) | |
print(ESET) | |
print(ASET.issubset(BSET)) | |
print(BSET.issuperset(ASET)) | |
print(3 in ASET) | |
print(5 not in ASET) | |
##Dictionary Veri Yapisi | |
cityDic ={"İstanbul" :"34","Diyabakir":"21","Isparta":"32"} | |
##İstanbul anahtar 34 value dir | |
##Sözlügü veri eklemek | |
cityDic["ADANA"]="0" | |
cityDic["İzmir"]="35" | |
##öge degiştir | |
cityDic["İstanbul"]="12" | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment