From 3cc7211892a35abf9bf352a5c4f505d291950488 Mon Sep 17 00:00:00 2001 From: hilalguler111 <79762223+hilalguler111@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:49:13 +0200 Subject: [PATCH 1/5] week 3 --- perfectnumbers.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) create mode 100644 perfectnumbers.py 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 From 8d8d2bbbc9f76493dc31354f3f72917ea97fb974 Mon Sep 17 00:00:00 2001 From: hilalguler111 <79762223+hilalguler111@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:50:07 +0200 Subject: [PATCH 2/5] week 3 --- alphabetical_order.py | 6 ++++++ 1 file changed, 6 insertions(+) create mode 100644 alphabetical_order.py 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 From 8f0d6968024d189474734ffbcde31f9291f69401 Mon Sep 17 00:00:00 2001 From: hilalguler111 <79762223+hilalguler111@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:50:44 +0200 Subject: [PATCH 3/5] week 3 --- reading_number.py | 9 +++++++++ 1 file changed, 9 insertions(+) create mode 100644 reading_number.py 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 From 473c0ebbcf7866433bc396d8e04fe0f75efc9fb8 Mon Sep 17 00:00:00 2001 From: hilalguler111 <79762223+hilalguler111@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:51:25 +0200 Subject: [PATCH 4/5] week 3 --- unique_list.py | 8 ++++++++ 1 file changed, 8 insertions(+) create mode 100644 unique_list.py 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 From 9ba128a2996ce298a99283ba4140dce92ef6ae36 Mon Sep 17 00:00:00 2001 From: hilalguler111 <79762223+hilalguler111@users.noreply.github.com> Date: Thu, 30 Sep 2021 22:52:01 +0200 Subject: [PATCH 5/5] week 3 --- equal_reverse.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) create mode 100644 equal_reverse.py 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")