Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions alphabetical_order.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#alphabetical order
def alphabetical():
words=input("Enter some words and add hyphen between them: ") #I wanted to ask from user to enter some words with hyphen
source=[n for n in words.split('-')] #I defined a source list and it is equal all of the words with hyphen
source.sort() #I sorted the list with an alphabetical order
print('-'.join(source))# I wrote to the screen a print which added hyphen

alphabetical()
10 changes: 10 additions & 0 deletions equal_reverse.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
#equal deverse
def equal_devers(*args): #I defined a function with args
words=[] #I opened a new empty list
for i in args: #I wanted to look all elements
if i==i[::-1]: #If their reverse is equal to them
words.append(True) #If it is equal I added True to the words list
else:
words.append(False) # If it is not equal I added False to the words list
return words #I wanted to return words list from the function
print(equal_devers("madam","tacocat","utrecht"))
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

tebrikler. sonradan fark ettim: son 2satir bu sekilde daha iyi olabilir. yani fonksiyon cagrisi print icinde olmasin bence.
return print(words)
equal_devers("madam","tacocat","utrecht")

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Abi yeni gordum yorumunuzu. Tesekkurler yorumunuz icin.

12 changes: 12 additions & 0 deletions perfect_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
#perfect numbers
from functools import reduce # I called the reduce from functools
def perfect_number(n):
sum = 0 # I defined sum and it is equal to 0
for x in range(1, n): #I returned the function to the number that user enter it.
if n % x == 0: #if the remainder of the division is equal 0
sum += x #add x to the sum
return sum == n #return it if sum equal to n which is entered by the user.
new_list=list(filter(perfect_number,range(1,1000))) #I defined a new list and it is equal to a new list which is filter by the function
sum=reduce(lambda a,b: a+b,new_list)#sum is equal to a number which is the sum of perfect numbers
print (new_list)
print(sum)
13 changes: 13 additions & 0 deletions reading_number.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
#reading numbers
def reading_numbers(): # I defined a fuction
x=int(input("Please a number with two digits: ")) #I wanted to ask from user to enter a number with two digits
list=["ten","eleven","twalf","thirteen","fourteen","fifteen","sixteen","seventeen","ëighteen","nineteen"] # I defined three lists
first_digit=["","one","two","three","four","five","six","seven","eight","nine"]
second_digit=["","","twenty","thirty","fourty","fifty","sixty","seventy","eighty","ninety"]
first=x%10 #I defined first is equal the first digit of the number
second=x//10 # I defined second is equal to the second digit of the number
if 10<=x<20: # if the number equal to ten or small than twenty
print(list[first]) # I wanted to print to the elememt of the list which is order in the first position
else:
print(second_digit[second],first_digit[first])# if it is others the reading of the number equal to second postion of the secondigit list
reading_numbers() #and first position of the firstdigit list
8 changes: 8 additions & 0 deletions unique_list.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
#unique list
def unique_list(*args): #I defined a function with args
new_list=[] # I opened a new list
for i in args: #For every lements in args
if i not in new_list: #I wanted to search if this element is not in args
new_list.append(i) #if the element doesn't exist in new list I add with the append properties
return new_list # I wanted to take this new list from the function
print(unique_list(1,2,3,3,4,4,6,6,4,5,5))