Created
May 25, 2020 14:34
-
-
Save jigi-33/4e0d97c41fde3a6046451b94451b4e87 to your computer and use it in GitHub Desktop.
Множества - нахождения уникальных элементов, разностей в строках, списках и прочих массивах
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
""" | |
STRINGS, SETS, SEQUENCES | |
""" | |
# Принимаем на вход две строки и выводит на экран все буквы из первой строки, которые отсутствуют во второй строке | |
s1 = input('Введите первую строку:') | |
s2 = input('Введите вторую строку:') | |
answ = list(set(s1) - set(s2)) | |
# Принимаем на вход две строки и находим в них ОБЩИЕ буквы | |
s1 = input("Введите первую строку:") | |
s2 = input("Введите вторую строку:") | |
answ = list(set(s1) & set(s2)) | |
# Подсчет гласных в строке | |
s = input("Введите строку:") | |
count = 0 | |
vowels = set('aeiou') | |
for letter in s: | |
if letter in vowels: | |
count += 1 | |
print(count) | |
# Считываем число n и выводим на экран все Промежуточные Суммы последовательностей 1, 2 … до n. | |
n = int(input("Введите число: ")) | |
for j in range(1, n+1): | |
a=[] | |
for i in range(1, j+1): | |
print(i, sep=" ", end=" ") | |
if(i < j): | |
print("+", sep=" ", end=" ") | |
a.append(i) | |
print("=", sum(a)) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment