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 stefanyshynni/first/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
""""
Дано список.
Вивести кількість елементів списку типу string
"""

list1 = list(input('список='))
k = 0
if isinstance(list1[k], str):
k += 1
print(k)
Comment on lines +5 to +10

Choose a reason for hiding this comment

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

оскільки список дано, то використання функціїї введення користувачем input() не є коректним. Поставлену задачу краще виконати так:
list1 = [65, True, 67.87, 'cola', 'pepsi', 34, 'what']
str_count = 0
for element in list1:
if isinstance(element, str):
str_count+=1

print('Кількість елементів списку типу string: ', str_count)

12 changes: 12 additions & 0 deletions stefanyshynni/first/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,12 @@
"""
Дано текст.
Видалити елементи значення integer
"""

text1 = str(input('text:'))
list1 = ','.join(list(text1))
n = 0
if isinstance(list1[n], int):
list1.remove(str)
n += 1
print (list1)
Comment on lines +6 to +12

Choose a reason for hiding this comment

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

list_text = [32434.332, 'dssd', 32234, '3234']
len_of_list = len(list_text)
for element in list_text:
if type(element) == int:
list_text.remove(element)
print(list_text)

9 changes: 9 additions & 0 deletions stefanyshynni/first/task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Дано текст.
Перші літери перевести у верхній регістр, а решту - в нижній.
"""

import string
text1 = list(input('Введіть текст:'))
text2 = text1
print(text2)
Comment on lines +6 to +9

Choose a reason for hiding this comment

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

Програма не виконує поставлене завдання. Виконання завдання слід реалізувати так:

Tim Dorotyuk, [24.12.19 01:23]
text1 = input('Введіть текст:')
text_list = text1.split()
res_list = []
for element in text_list:
res_list.append(element.capitalize())
result_string = ' '.join(res_list)
print(result_string)

19 changes: 19 additions & 0 deletions stefanyshynni/second/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
"""
Написати валідатор для вводу та виводу даних на мові програмування Паскаль
"""

import re
def validator ():
text = input('Введіть дані:')
if bool(re.compile('^(Begin){1}\\n writeln{0,+}readln{0,+}(Begin){0,1} writeln{0,+}readln{0,+} end{0,1}\\n end{1}$',text)):
print ('Yes')
else:
print ('no')
validator()

flag = input('для запуску програми натисніть \"Enter\", щою завершити програми \"n\"')
if flag != 'n':
validator()
flag = input('для запуску програми натисніть \"Enter\", щою завершити програми \"n\"')
else:
print('Допобачення')
Comment on lines +5 to +19

Choose a reason for hiding this comment

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

Для того, аби програма нормально працювала, слід переписати регулярний вираз, а такжо замінити compile на match. Після цих змін програма має виглядати наступним чином:

import re
def validator ():
text = input('Введіть дані:')
if bool(re.match('[(Begin){1,2}(writeln())+(end){1,2}]',text)):
print ('Yes')
else:
print ('no')
validator()

flag = input('для запуску програми натисніть "Enter", щою завершити програми "n"')
if flag != 'n':
validator()
flag = input('для запуску програми натисніть "Enter", щою завершити програми "n"')
else:
print('Допобачення')