Test Engineering Notes
3.81K subscribers
177 photos
2 videos
648 links
Україномовний канал про технічні аспекти тестування, розподілені системи, блокчейн.

Консультації з автоматизації, менторинг, тестові співбесіди - @al8xr
Download Telegram
Найшвидший спосіб знайти голосні в реченні

#python

Задача: написати функцію, яку перевіряє чи є голосні в рядку.


def has_vowels(s: str) -> bool:
...


Можна це зробити багатьма способами.

Спосіб 1


def loop_in(s):
for c in s:
if c in "aeiouAEIOU":
return True
return False


Спосіб 2


def set_intersection(s):
return set(s) & set("aeiouAEIOU")


Спосіб 3


def map_lambda(s):
return any(map(lambda x: x in "aeiouAEIOU", s))


Але виявляється, що найшвидший спосіб це - регулярні вирази!


import re
def regex(s):
return bool(re.search(r'[aeiouAEIOU]', s))


Чому? Бо механізм регулярних виразів в Python дуже оптимізований. Більше можна почитати в оригінальній статті.
👍23❤‍🔥51
Як ШІ замінить менеджерів

#python #ai


import time
import random

def random_status_prompt():
prompts = [
"What is your current status?",
"Any blockers?",
"Update your JIRA, please."
]

# Sleep for a random number of minutes (converted to seconds)
sleep_minutes = random.randint(1, 10)
print(f"Sleeping for {sleep_minutes} minute(s)...")
time.sleep(sleep_minutes * 60)

# Pick a random prompt and display it
message = random.choice(prompts)
print(message)

if __name__ == "__main__":
random_status_prompt()
😁67👏1