Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions nadya/first/task1.py
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)

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)

10 changes: 10 additions & 0 deletions nadya/first/task2.py
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)

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok is everything
def task2(text): count = 0 for i in text: if i.isdigit(): count = count + 1 print(count)

9 changes: 9 additions & 0 deletions nadya/first/task3.py
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])

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ok is everything
def task2(): text = "ghkdlh5673bjhdvfl" count = 0 for i in text: if i.isdigit(): count = count + 1 print(count)

Empty file added nadya/second/__init__.py
Empty file.
26 changes: 26 additions & 0 deletions nadya/second/task1.py
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:

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Краще використати
if elem in new_text[1::2]:

lis.append(elem)
print(lis)
for i in range(len(lis)-1):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Використовуйте
range(len(lis))

amount=re.findall(lis[i], text)
amount_list.append(len(amount))

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Всуньте amount_list.append(len(amount)) в for

print(amount_list, lis)
for i in range(len(lis)-1):

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Використовуйте
range(len(lis))

fin_list.append([lis[i], amount[i]])
print(fin_list)
find_most_frequent(text)