-
Notifications
You must be signed in to change notification settings - Fork 51
Ready for codereview #45
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: master
Are you sure you want to change the base?
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,10 @@ | ||
| """ | ||
| задан список з різними типами даних | ||
| вивести кількість елементів типу float | ||
| """ | ||
| newlist=["k",6.8,99,345,True,"66"] | ||
| count=0 | ||
| for i in newlist: | ||
| if isinstance(i,float): | ||
| count=count+1 | ||
| print(count) | ||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,10 @@ | ||
| """ | ||
| задан рядок | ||
| вивести кількість чисел у рядку | ||
| """ | ||
| text="ghkdlh5673bjhdvfl" | ||
| count=0 | ||
| for i in text: | ||
| if i.isdigit(): | ||
| count=count+1 | ||
| print(count) | ||
|
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. ok is everything |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,9 @@ | ||
| """ | ||
| дано рядок тексту | ||
| вивести кожне друге слово з кінця | ||
| """ | ||
| text="Just always and always look around and act wisely" | ||
| newlist=list(text.split(" ")) | ||
| rang=len(newlist) | ||
| for i in range(rang-2, -1, -2): | ||
| print(newlist[i]) | ||
|
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. ok is everything |
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,26 @@ | ||
| """ | ||
| Заданий рядок тексту. | ||
| Вивести список, що складається с елементів-списків, де перший елемент-кожне друге слово, в другий- кількість його повторів у реченні | ||
| """ | ||
| import re | ||
| lis=[] | ||
| amount_list=[] | ||
| fin_list=[] | ||
| text="HI there, i have double-cheese in my bag" | ||
|
|
||
| def find_most_frequent(text): | ||
| new_text=re.findall("\w+", text) | ||
| print(new_text) | ||
| for elem in new_text: | ||
| for i in range(len(new_text)-1):#range 0-8 | ||
| if i%2==1: | ||
|
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. Краще використати |
||
| lis.append(elem) | ||
| print(lis) | ||
| for i in range(len(lis)-1): | ||
|
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. Використовуйте |
||
| amount=re.findall(lis[i], text) | ||
| amount_list.append(len(amount)) | ||
|
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. Всуньте |
||
| print(amount_list, lis) | ||
| for i in range(len(lis)-1): | ||
|
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. Використовуйте |
||
| fin_list.append([lis[i], amount[i]]) | ||
| print(fin_list) | ||
| find_most_frequent(text) | ||
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.
ok is everything
newlist=["k", 6.8, 99, 345, True, "66"] def count(newlist): count=0 for i in newlist: if isinstance(i,float): count=count+1 print(count)