Skip to content

Conversation

@JoniNoct
Copy link

No description provided.

Підрахувати кількість порожніх листів
"""
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))

`

return result_str

def day_counter(user_list):
day_list = ["Понедельник","Вторник","Среда","Четверг","Пятница","Суббота","Воскресенье"]

Choose a reason for hiding this comment

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

Дні тижня слід писати українською мовою

"""
Вивести усі слова, що містять цифру 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))`


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

Choose a reason for hiding this comment

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

Не вистачає обробки високосного року.
`
if int(user_list[2]) % 4 == 0:
sum_of_days = (int(user_list[2])*365) + (int(user_list[1])*31) + (int(user_list[0])) + (int(user_list[2])//4)
res = day_list[(sum_of_days % 7)]
elif int(user_list[2]) % 4 != 0:
sum_of_days = (int(user_list[2]) * 365) + (int(user_list[1]) * 31) + int(user_list[0])
res = day_list[(sum_of_days % 7)-1]
return res

`

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))

`

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants