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
5 changes: 5 additions & 0 deletions dahnovskauo/first/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
'''
Вивести кількість порожніх списків
'''
a = [1, 3, 'a', 123, [], 'hello', []]
print('Кількість порожніх списків:', a.count([]))
10 changes: 10 additions & 0 deletions dahnovskauo/first/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,10 @@
'''
Вивести з тексту слова з великої літери
'''
text = str(input('Введіть рядок:'))
list = []
text =text.split(" ")
for word in text:
if (i.isupper() for i in word):

Choose a reason for hiding this comment

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

Change condition to "word[0].isupper()"

list.append(word)
print(list)
20 changes: 20 additions & 0 deletions dahnovskauo/first/task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
'''
Вивести суму усіх елементів списку, що являють собою числа, та окремо вивести рядочок, який складається з усіх рядочків
'''
list = [2, 8, 'w', 'j', []]
sum = 0
q = ''
for i in range(len(list)):
if isinstance(list[i], int):
sum = sum + list[i]
elif isinstance(list[i], str):
q = q + list[i] +' '

Choose a reason for hiding this comment

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

delete this: +' '

else:
print('Кінець')
Comment on lines +12 to +13

Choose a reason for hiding this comment

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

delete this
else: print('Кінець')

print('Сума:', sum)
print('Конкатенація:', q)





22 changes: 22 additions & 0 deletions dahnovskauo/second/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,22 @@
'''
Користувач вводить час у форматі `hh:mm(:ss(.ms))`, де дужки позначають необов'язковість.
Напишіть функцію, що повертає кількість повних секунд, що пройшли з опівночі.
Виведіть результат.
У випадку помилкового вводу виведіть повідомлення про помилку.
'''

import re
re_form = re.compile(r'/d/d')

Choose a reason for hiding this comment

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

change this: /d/d to this: \d\d

def validator(pattern, promt):
text = input(promt)
while not bool(pattern.match(text)):
text = input(promt)
return text

hours = int(validator(re_form ,'Введіть години hh:'))
min = int(validator(re_form ,'Введіть хвилини mm:'))
sec = int(validator(re_form ,'Введіть секунди(необ.) ss:'))
msec = int(validator(re_form ,'Введіть мілісекунди(необ.) ms: '))

time = hours*3600 + min*60 + sec + msec*0.001
print(time)

Choose a reason for hiding this comment

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

name programs output: print("Результат: " + time)`