-
Notifications
You must be signed in to change notification settings - Fork 12
week3 hw #13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
week3 hw #13
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| ##3-alphabetical_order.py | ||
|
|
||
| def words (): | ||
| x, y, z, w = input("please enter four word:").split("-") | ||
| list=[x, y, z, w] | ||
| list.sort() | ||
| for i in list: | ||
| print(i,end="-") | ||
| print(words()) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| ##5-equal_reverse.py | ||
|
|
||
| def isPalindrome(s): | ||
| return s == s[::-1] | ||
| s = input("enter a word :") | ||
| ans = isPalindrome(s) | ||
| if ans: | ||
| print("true") | ||
| else: | ||
| print("false") | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. temiz ve kisa cozum tebrikler |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,13 @@ | ||
| ##1-perfect_number.py | ||
|
|
||
| def perfect (): | ||
| perfectlist=[] | ||
| for i in range (1,1000): | ||
| sum=0 | ||
| for j in range (1,i): | ||
| if i%j==0: | ||
| sum +=j # sum all divisor | ||
| if sum == i: # if sum of divisor equal to number it means number is perfect | ||
| perfectlist.append(i) | ||
| return print(perfectlist) | ||
| print(perfect()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tebrikler. sadece 1- fonksiyon cagrisini print icinde yapmayin. none ciktisi veriyor buyuzden son satirda. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,19 @@ | ||
| ##2-reading_number.py | ||
|
|
||
| def read (): | ||
| number = int(input("please enter a number:")) | ||
| ones=["", "one", "two", "three", "four", "five", "six", "seven", "eight", "nine"] | ||
| tens=["", "teen", "twenty", "thirty", "fourty", "fifty", "sixty", "seventy", "eighty", "ninety"] | ||
| one = number%10 # we find ones digit | ||
| ten = number//10 #we find tens digit | ||
| if ten == 1 and one == 1: # for 11 | ||
| return print("eleven") | ||
| elif ten ==1 and one == 2: # for 12 | ||
| return print("twelve") | ||
| elif ten ==1 and one == 3: # for 13 | ||
| return print("thirteen") | ||
| elif ten==1 and one != 1 and one !=2 and one != 3: # without 10+(1, 2, 3) ; 14,15... | ||
| return print(ones[one], "teen") | ||
| else: | ||
| return print(tens[ten], ones[one]) # write without {} + teen. it is 20,21,22,... | ||
| print(read()) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. yorum satirlari eklenebilir. |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,8 @@ | ||
| ##4-unique_list.py | ||
| # Write a function that filters all the unique(unrepeated) elements of a given list. | ||
|
|
||
| def unique_list(test_list): | ||
| res = [] | ||
| [res.append(x) for x in test_list if x not in res] | ||
| return res | ||
| print (unique_list([1, 1, 1, 2, 2, 3, 3])) | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. tebrikler. yorum satiri ve fonksiyon cagrisi daha iyi olabilir |
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
cok guzel fakat fonksiyonu cagrisini print fonksiyonu icinde yazdiginiz icin none degeri yazdiriyor ensonda. son satir sadece: words() yeterli. Ancak bu seferde son kelimenin sonuna - isareti yazar. onuda biraz daha dusunseniz temizlenir. mesela for loop icine if i==list[-1]: gibi bir sart koyarak yada baska yollar bulunabilir