Подготовка к собеседованию на Junior Python Developer. В этом канале никакой воды, только вопросы с собеседований и ответы на них.
@aldrson
По вопросам рекламы : @anothertechrock
Post #831
4.01K
- ❤ 3
PY @pythonjuniorjob
Showing posts older than #833 · Back to latest
best_friend("he headed to the store", "h", "e") ➞ True
# Вхождения "h": ["he", "headed", "the"]
# После всех вхождений "h" идет буква "e".
# Возвращается True
Другие примеры:best_friend("he headed to the store", "h", "e")
➞ True
best_friend("i found an ounce with my hound", "o", "u")
➞ True
best_friend("we found your dynamite", "d", "y")
➞ Falserectangle_in_circle(8, 6, 5) ➞ True
rectangle_in_circle(5, 9, 5) ➞ False
rectangle_in_circle(4, 7, 4) ➞ Falsecorrect_spacing("The film starts at midnight. ")
➞ "The film starts at midnight."
correct_spacing("The waves were crashing on the shore. ")
➞ "The waves were crashing on the shore."
correct_spacing(" Always look on the bright side of life.")
➞ "Always look on the bright side of life."min_difference_pair([40, 16, 8, 17, 15])
➞ [15, 16]
# Сумма [15, 16] меньше, чем сумма [16, 17]
min_difference_pair([1, -31, -27, -18, -48, -15, -11, -34])
➞ [-34, -31]
min_difference_pair([0, 2, 35, 42, 45, 14, -6, -1])
➞ [-1, 0]
min_difference_pair([32, 33, 4, 6, 48, 18, 20, -7, -4, 31])
➞ [31, 32]def num_of_digits(n):Еще 3 варианта решения мы закинули на наш сайт: https://pythonturbo.ru/zadacha-najdite-kolichestvo-czifr-v-chisle/
return next(i for i in range(1, 100) if abs(n) < 10**i)
num”.num_of_digits(1000) ➞ 4Пишите ваши варианты решения в комментах. Варианты решений будут скоро(сегодня-завтра)
num_of_digits(12) ➞ 2
num_of_digits(1305981031) ➞ 10
num_of_digits(0) ➞ 1
three_letter_collection("python") ➞ ["hon", "pyt", "tho", "yth"]
# 1-я группа: "hon"
# 2-я группа: "pyt"
# 3-я группа: "tho"
# 4-я группа: "yth"
# Не забудьте отсортировать список!
Примерыthree_letter_collection("slap") ➞ ["lap", "sla"]
three_letter_collection("click") ➞ ["cli", "ick", "lic"]
three_letter_collection("cat") ➞ ["cat"]
three_letter_collection("hi") ➞ []def char_index(word, char):Еще 3 варианта решения мы закинули на наш сайт: https://pythonturbo.ru/zadacha-pervyj-i-poslednij-indeks/
return None if char not in word else [word.index(char), word.rindex(char)]
char_index("hello", "l") ➞ [2, 3]
# Первая "l" имеет индекс 2, последняя "l" - индекс 3.
char_index("circumlocution", "c") ➞ [0, 8]
# Первая "c" имеет индекс 0, последняя "c" - индекс 8.
char_index("happy", "h") ➞ [0, 0]
# В слове есть только одна буква "h", поэтому и первый, и последний индекс равны 0.
char_index("happy", "e") ➞ None
# Символа "e" в "happy" нет, поэтому мы возвращаем None.
Пишите ваши варианты решения в комментах. Варианты решений будут скоро(сегодня-завтра)def missing_num(lst):Еще 3 варианта решения мы закинули на наш сайт: https://pythonturbo.ru/zadacha-najdite-nedostayushhee-chislo/
return 55 - sum(lst)
missing_num([1, 2, 3, 4, 6, 7, 8, 9, 10]) ➞ 5Пишите ваши варианты решения в комментах. Варианты решений будут скоро(сегодня-завтра)
missing_num([7, 2, 3, 6, 5, 9, 1, 4, 8]) ➞ 10
missing_num([10, 5, 1, 2, 4, 6, 8, 3, 9]) ➞ 7
def fact_of_fact(n):Еще 3 варианта решения мы закинули на наш сайт: https://pythonturbo.ru/zadacha-faktorial-faktorialov/
f = count = 1
for i in range(1, n + 1):
f *= i
count *= f
return count
fact_of_fact(4) ➞ 288Пишите ваши варианты решения в комментах. Варианты решений будут скоро(сегодня-завтра)
# 4! * 3! * 2! * 1! = 288
fact_of_fact(5) ➞ 34560
fact_of_fact(6) ➞ 24883200