diff --git a/Week03_Hw4.py b/Week03_Hw4.py new file mode 100644 index 0000000..7ec03a6 --- /dev/null +++ b/Week03_Hw4.py @@ -0,0 +1,23 @@ + +## 4-unique_list.py +##Write a function that filters all the unique(unrepeated) elements of a given list. + + + +def unique(list): + + unique_list = [] + + for x in list: + + if x not in unique_list: + unique_list.append(x) + + for x in unique_list: + print(x) + +list = [1,2,3,3,3,3,4,5,5] + +print(unique(list)) + + diff --git a/Week03_Hw5.py b/Week03_Hw5.py new file mode 100644 index 0000000..5991f80 --- /dev/null +++ b/Week03_Hw5.py @@ -0,0 +1,13 @@ + +# function which return reverse of a string + +def return_reserve(x): + return x == x[::-1] + +x = input("check your word reserve or not, please enter your word : ") +y = return_reserve(x) + +if y: + print("Yes") +else: + print("No") diff --git a/Week03_Hw_1.py b/Week03_Hw_1.py new file mode 100644 index 0000000..947d7f4 --- /dev/null +++ b/Week03_Hw_1.py @@ -0,0 +1,10 @@ +##Write a function that finds perfect numbers between `1` and `1000`. +##Check perfect numbers between `1` and `1000` and find the sum of the perfect numbers using reduce and filter functions. + +def perfect(x): + return [y for y in range(1, int(x / 2) + 1) if x % y == 0] + +def perfect_numbers_in_range(a,b): + return [x for x in range(a,b+1) if sum(perfect(x)) == x] + +print(perfect_numbers_in_range(1, 10000)) diff --git a/Week03_Hw_2.py b/Week03_Hw_2.py new file mode 100644 index 0000000..a41c782 --- /dev/null +++ b/Week03_Hw_2.py @@ -0,0 +1,15 @@ + +#write a function that outputs the transcription of an input number with two digits. + + +def transcription(n): + + units_digits=['','one','two','tree','four','five','six','seven','eight','nine'] + tens_digits=['','','twenty','thirty','fourty','fifty','sixty','seventy','eighty','ninety'] + units=n%10 + tens=n//10 + print(tens_digits[tens],units_digits[units]) + +number=int(input("enter number with two digits : ")) +transcription(number) + diff --git a/Week03_Hw_3.py b/Week03_Hw_3.py new file mode 100644 index 0000000..14906d5 --- /dev/null +++ b/Week03_Hw_3.py @@ -0,0 +1,10 @@ +def abccc(): + + items=[i for i in input().split('-')] + items.sort() + +#print('-'.join(abccc)) + +print(abccc) + +