diff --git a/AlphabeticalOrder.py b/AlphabeticalOrder.py new file mode 100644 index 0000000..39de1d9 --- /dev/null +++ b/AlphabeticalOrder.py @@ -0,0 +1,10 @@ +print("-"*75) +print(str("-") *30 +"ALPHABETICAL ORDER"+ str("-")*27) +print("-"*75) +def alphabetical_order(): # alphabetical_order adinda bir function yaziyoruz. + word=input("Enter some words with a (-) between them ")# user dan aralarinda - olan kelimeler istiyoruz. + word=word.lower() # buyuk harf kullaniminin onune gecmek icin harfleri kucultuyoruz. + word_split=sorted(word.split("-")) # yazilan kelimeri - isaretinden split yapip siraliyoruz. + result= "-".join(word_split) #kelimeler arasina join metodu nu kullanarak - ekliyoruz. + return result # ve result u return yapiyoruz. +print(alphabetical_order()) # function u cagiriyoruz. \ No newline at end of file diff --git a/EqualReverse.py b/EqualReverse.py new file mode 100644 index 0000000..b0ff90d --- /dev/null +++ b/EqualReverse.py @@ -0,0 +1,15 @@ +print("-"*75) +print(str("-") *30 +"EQUAL REVERSE"+ str("-")*27) +print("-"*75) +def equal_reverse(): + word=input("Enter some words to check if they are equal \nto the reverse order of words.Use (,) between them -> ") + word = word.lower() # userdan verdigi kelimelerin tersine esit olup olmadigini ogrenmesi icin bazi kelimeler isiyoruz. + word_split=word.split(",") # verilen kelimeri kucuk harflere donusturup virgulden split yapiyoruz. + a=[] # bir a bos listesi olusturup for loop unu kullanarak split edilmis kelimeleri + for i in word_split: # geziyoruz.eger kelime tersine esitse "True" deilse "False" ekliyoruz. + if i==i[::-1]: + a.append("True") + else: + a.append("False") + return ", ".join(a) # def functionun sonunda True False larin arasina virgul koyarak return esiyoruz. +print(equal_reverse()) #equal_reverse function cagiriyoruz. \ No newline at end of file diff --git a/HackerrankCapitalize.py b/HackerrankCapitalize.py new file mode 100644 index 0000000..a6a6b56 --- /dev/null +++ b/HackerrankCapitalize.py @@ -0,0 +1,11 @@ +print("-"*75) +print(str("-") *30 +"CAPITALIZE"+ str("-")*35) +print("-"*75) + +def solve(s): #solve adinda bir def functionu olusturuyoruz + a=s.split(" ") # verilen degeri bosluktan split ediyoruz. + b=[] + for i in a: #split edilmis a yi for loop ile gezip + b.append(i.capitalize()) #her kelimenin bas harfini buyuk yapiyoruz + return " ".join(b) # functionun sonunda kelimelrin arasina bosluk ile return ediyoruz. +print(solve("bulent caliskan")) #functionu bir deger ile cagiriyoruz. diff --git a/PerfectNumber.py b/PerfectNumber.py new file mode 100644 index 0000000..643bc88 --- /dev/null +++ b/PerfectNumber.py @@ -0,0 +1,17 @@ +print("-"*75) +print(str("-") *30 +"PERFECT NUMBER"+ str("-")*31) +print("-"*75) +def perfect_number(): # perfect number adinda bir def function olusturuyoruz. + while True: #devamli donecek olan while loop unu yaziyoruz. + try: # try except metodu ile sayidan baska bir sey girilirse hata dan kacinmis + # ve tekrar loopun basina donuyoruz. + x = int(input(" Enter a number between 1 and 1000 ? ")) #user dan 1 ile 1000 arasinda bir sayi girmesini istiyoruz. + if 1 <= x <= 1000 : # eger sayi 1 ile 1000 arasinda olassa else iel tekrar loop un basina yolluyoruz + divisible_list=[i for i in range(1,x) if x % i == 0 ] # x e kadar olan sayilarin x e bolunebilenleri listeye aktariyoruz. + return ("{} is perfect number".format(x) if sum(divisible_list)==x else "{} is not perfect number".format(x)) + # return ile listedeki sayilarin toplaminin x e esit olup olmadigini denetliyoruz. + else: # esit ise x is perfect number deilse x is not perfect number return ediyoruz + continue + except: + continue +print(perfect_number()) # ensonda da perfect_number fonctionu nu cagiriyoruz. \ No newline at end of file diff --git a/ReadingNumber.py b/ReadingNumber.py new file mode 100644 index 0000000..b90923a --- /dev/null +++ b/ReadingNumber.py @@ -0,0 +1,29 @@ +print("-"*75) +print(str("-") *30 +"READING NUMBER"+ str("-")*31) +print("-"*75) +def reading_number(): # reading number adinda bir def function tanimliyoruz. + while True: # programdan cikilmadigi takdirde donen bir while loop u yaziyoruz + try: # yanlis inputlardan kacinmak icin try except metodunu kullaniyoruz. + x=input("Enter a two digit number ? ") #user dan iki basamakli bir sayi girmesini istiyoruz ve x variable ina atiyotuz. + if len(x)==2: # if else ile sayinin iki basamakli olup olmadigina bakiyoruz.Deilse loop un basina yolluyoruz. + ones_digit=["","one","two","three","four","five","six","seven","eight","nine"] # verecegimiz outputlari 3 liste seklinde hazirliyoruz. + tens_digit=["","Ten","Twenty","Thirty","Fourty","Fifty","Sixty","Seventy","Eighty","Ninety"] + decimals=["","Eleven","Twelve","Thirteen","Fourteen","Fifteen","Sixteen","Seventeen","Eighteen","Nineteen"] + if x[1]=="0": # eger x sayisinin birler basamagi 0 ise girecek if statment yaziyoruz. + a= [i for i in tens_digit if int(x[0])== tens_digit.index(i)] # for ile tens_digit listesini geziyoruz ve eger x in onlar basamagi + return "{} ---------> {}".format(x,a[0]) #tens_digit deki br elemanin index ine esitse print olmasi gereken ifadeyi return yapiyoruz. + elif x[0]=="1": #eger x sayisinin onlar basamagi 1 ise girecek if statment yaziyoruz. + a=[i for i in decimals if int(x[1])== decimals.index(i)] #for ile decimals listesini geziyoruz ve eger x in birler basamagi + return "{} ---------> {}".format(x,a[0]) #decimal deki br elemanin index ine esitse print olmasi gereken ifadeyi return yapiyoruz. + else: + last1=[i for i in tens_digit if int(x[0])==tens_digit.index(i)] # ilk iki ifade calismassa else stament calisir.burada last1 ve + last2=[i for i in ones_digit if int(x[1])== ones_digit.index(i)] #last2 listesini yukarda anlatilan gibi olusturuyoruz. + return "{} ---------> {}-{}".format(x, last1[0], last2[0]) # ve return olmasi gereken ifadeyi return ediyoruz. + else: + print("You did not enter two digit number! ") + continue + except: + print("You did not enter two digit number! ") + continue + +print(reading_number()) \ No newline at end of file diff --git a/UniqueList.py b/UniqueList.py new file mode 100644 index 0000000..d164051 --- /dev/null +++ b/UniqueList.py @@ -0,0 +1,10 @@ +print("-"*75) +print(str("-") *30 +"UNIQUE LIST"+ str("-")*27) +print("-"*75) +def unique_list(x): # unique_list adinda bir def function olusturuyoruz. + a=[] # unique olan elemanlari atacagimiz bos list olusturuyoruz. + for i in x: # x in icinde birden fazla olan elemanlari a listesine atiyoruz. + if i not in a: + a.append(i) + return "Your list --> {}\nUnique list --> {}".format(x,a) # sonda verilen listeyi ve unique listesini return yapiyoruz. +print(unique_list([1,2,3,3,3,3,4,5,5])) # unique_list function i bir liste ile cagiriyoruz. \ No newline at end of file