diff --git a/alphabetical_order.py b/alphabetical_order.py new file mode 100644 index 0000000..4878fcc --- /dev/null +++ b/alphabetical_order.py @@ -0,0 +1,6 @@ +def alphabetical_order(): + n=input("enter the words: ") + l=n.split('-') + l.sort() + print('-'.join(l)) +alphabetical_order() \ No newline at end of file diff --git a/equal_reverse.py b/equal_reverse.py new file mode 100644 index 0000000..d02e9af --- /dev/null +++ b/equal_reverse.py @@ -0,0 +1,22 @@ +def isPalindrome(s): + return s == s[::-1] + + +s = "madam" +ans = isPalindrome(s) + +if ans: + print("Yes") +else: + print("No") +def isPalindrome(s): + return m == m[::-1] + + +m = "utrecht" +ans = isPalindrome(m) + +if ans: + print("Yes") +else: + print("No") diff --git a/perfectnumbers.py b/perfectnumbers.py new file mode 100644 index 0000000..b570319 --- /dev/null +++ b/perfectnumbers.py @@ -0,0 +1,24 @@ +from functools import reduce +L=[] +def isPerfect( n ): + + + sum = 1 + + i = 2 + while i * i <= n: + if n % i == 0: + sum = sum + i + n/i + i += 1 + + + return (True if sum == n and n!=1 else False) +print("Below are all perfect numbers till 10000") +n = 2 +for n in range (10000): + if isPerfect (n): + print(n , " is a perfect number") + L.append(n) +print("Sum of perfect numbers:",reduce(lambda x,y:x+y,L)) + + \ No newline at end of file diff --git a/reading_number.py b/reading_number.py new file mode 100644 index 0000000..6d56eed --- /dev/null +++ b/reading_number.py @@ -0,0 +1,9 @@ +def yazi(a): + birler=["","bir","iki","uc","dort","bes","alti","yedi","sekiz","dokuz"] + onlar=["","on","yirmi","otuz","kirk","elli","altmis","yetmis","seksen","doksan"] + bir=a%10 + on=a//10 + print(onlar[on],birler[bir]) + +sayi=int(input("iki basamakli bir sayi giriniz")) +yazi(sayi) \ No newline at end of file diff --git a/unique_list.py b/unique_list.py new file mode 100644 index 0000000..7e6b416 --- /dev/null +++ b/unique_list.py @@ -0,0 +1,8 @@ +def unique_list(l): + x = [] + for a in l: + if a not in x: + x.append(a) + return x + +print(unique_list([1,2,3,3,3,3,4,5])) \ No newline at end of file