setx = set(["зеленый", "синий"])
sety = set(["синий", "желтый"])
print("\nПересечение множеств:")
setz = setx & sety
print(setz)
#coding #beginner
Pythonist.ru - помощь в подготовке к собеседованию на позицию Python Developer.
setx = set(["зеленый", "синий"])
sety = set(["синий", "желтый"])
print("\nПересечение множеств:")
setz = setx & sety
print(setz)
#coding #beginners — квадрат
- c — круг
Если в функцию передана буква s, то второй аргумент, число, считается длиной стороны квадрата. В противном случае число считается радиусом круга.
При написании функции из операторов можно использовать только арифметические и операторы сравнения. То есть, никаких:
- инструкций if… else
- словарей
- лямбд
- методов форматирования
Цель — написать короткий код без ветвления. Округлять ничего не нужно.
Примеры:
perimeter("s", 7) ➞ 28
perimeter("c", 4) ➞ 25.12
perimeter("c", 9) ➞ 56.52
Решение на нашем сайте.
#задача #codingfrom collections import Counter
import re
text = """The Python Software Foundation (PSF) is a 501(c)(3) non-profit corporation that holds the intellectual property rights behind the Python programming language. We manage the open source licensing for Python version 2.1 and later and own and protect the trademarks associated with Python. We also run the North American PyCon conference annually, support other Python conferences around the world, and fund Python related development with our grants program and by funding special projects."""
words = re.findall('\w+', text)
print(Counter(words).most_common(10))
#coding #beginner[('Python', 6), ('the', 6), ('and', 5), ('We', 2), ('with', 2), ('The', 1), ('Software', 1), ('Foundation', 1), ('PSF', 1), ('is', 1)]
Текст:
The Python Software Foundation (PSF) is a 501(c)(3) non-profit corporation that holds the intellectual property rights behind the Python programming language. We manage the open source licensing for Python version 2.1 and later and own and protect the trademarks associated with Python. We also run the North American PyCon conference annually, support other Python conferences around the world, and fund Python related development with our grants program and by funding special projects.
Пишите ответы в комментариях, а мы свой вариант опубликуем завтра.
#coding #beginnerhistogram([1, 3, 4], "#") ➞ "#\n###\n####" # ### #### histogram([6, 2, 15, 3], "=") ➞ "======\n==\n===============\n===" ====== == =============== === histogram([1, 10], "+") ➞ "+\n++++++++++" + ++++++++++Решение на нашем сайте. #задача #coding
n = 5
for i in range(n):
for j in range(i):
print('* ', end="")
print('')
for i in range(n, 0, -1):
for j in range(i):
print('* ', end="")
print('')
#coding #beginner