-
Notifications
You must be signed in to change notification settings - Fork 12
Week 3 #3
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
Open
theakers
wants to merge
2
commits into
fenyx-it-academy:main
Choose a base branch
from
theakers:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Week 3 #3
Changes from all commits
Commits
Show all changes
2 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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")) | ||
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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 |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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)) |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
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")
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.
Abi yeni gordum yorumunuzu. Tesekkurler yorumunuz icin.