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
9 changes: 9 additions & 0 deletions maistrukia/first/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
"""
Підрахувати кількість порожніх листів
"""
rand_list = ["asdasd", 1231, 1251.1001, [], [123, 123, "ASD"], "KSAJFKJO1", "1234124", [123, 321], [], [], 123, 123.123, [], [123]]
counter = 0

Choose a reason for hiding this comment

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

Зроблено за допомогою функцій
`
def empty_lists(list_1):
counter = 0
for element in list_1:
if isinstance(element, list) is True and len(element) == 0:
counter += 1
return int(counter)
print("Count of empty lists: ", empty_lists(rand_list))

`

for element in rand_list:
if isinstance(element, list) is True and len(element) == 0:
counter += 1
print("Count of empty lists: ", counter)
17 changes: 17 additions & 0 deletions maistrukia/first/task2.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
"""
Вивести усі слова, що містять цифру 9
"""
rand_text = "Adp9slp spldpsldpsl sdlpsldp sa9d aspdl as asldp asdpl asdlp a a9 a apsdl asd asdsap asd asdqwe qwe qweqw9rtfas qwrqawsfqwfxaf qpwl9dpsa"

Choose a reason for hiding this comment

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

Зроблено за допомогою функцій
`rand_text = "Adp9slp spldpsldpsl sdlpsldp sa9d aspdl as asldp asdpl asdlp a a9 a apsdl asd asdsap asd asdqwe qwe qweqw9rtfas qwrqawsfqwfxaf qpwl9dpsa"

def if_word_9(text):
rand_list = text.split()
result_str = ""
for word in rand_list:
counter = False
for letter in word:
if letter == "9":
counter = True
if counter is True:
result_str += word + " "
# print(word, end=" ")
else:
continue
return result_str
print(if_word_9(rand_text))`

rand_list = rand_text.split()
result_str = ""
for word in rand_list:
counter = False
for letter in word:
if letter == "9":
counter = True
if counter is True:
result_str += word + " "
# print(word, end=" ")
else:
continue
print(result_str)
11 changes: 11 additions & 0 deletions maistrukia/first/task3.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
"""
Користувач вводить два дійсних числа. Вивести всі числа кратні 3 на цьому проміжку.
"""
first_num = float(input("Enter the first number:"))
second_num = float(input("Enter the second number:"))

for num in range(int(first_num), int(second_num)+1):

Choose a reason for hiding this comment

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

Зроблено за допомогою функцій
`

def numb(start,end):
for num in range(int(start), int(end)+1):
if num % 3 == 0:
print(num)
else:
continue

print(numb(first_num,second_num))

`

if num % 3 == 0:
print(num)
else:
continue
27 changes: 27 additions & 0 deletions maistrukia/second/task1.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
import re

"""
Користувач вводить дату, визначити який день тижня припадає на цю дату. При урахуванні того, що 01.01.0001 припадає на понеділок
"""

def is_date(start_str):
return bool(re.match(r"^[1-30][1-90]-[01][1-90]-\d{4}$", start_str))

def date_validator(text=""):
result_str = input(text)
while not is_date(result_str):
result_str = input("Некоректно введено дату, введіть знову: ")
return result_str

def day_counter(user_list):
day_list = ["Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье"]
sum_of_days = (int(user_list[2])*365) + (int(user_list[1])*31) + int(user_list[0])

return day_list[(sum_of_days%7)-1]

print("Доброго дня. Введіть дату у форматі 31-12-0001: ")
user_date = date_validator()
user_date = re.split(r"-", user_date)
# print(user_date)
result_day = day_counter(user_date) # func day
print(result_day)