This file contains 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
letters = "А Б В Г Д Е Ё Ж З И Й К Л М Н О П Р С Т У Ф Х Ц Ч Ш Щ Ъ Ы Ь Э Ю Я" | |
divided_letters = letters.split() | |
def encrypt(s, k): | |
mod_letters = [] | |
for w in s.upper(): | |
if w in divided_letters: | |
index = divided_letters.index(w) + k | |
if index > len(divided_letters) or index < 0: |
This file contains 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
import datetime | |
try: | |
date_x = (input("Введите дату/время в формате ДД.ММ.ГГГГ ЧЧ:ММ : ")) | |
date_x = datetime.datetime.strptime(date_x, '%d.%m.%Y %H:%M') | |
date_x_new = date_x.replace(minute=date_x.minute + 1) | |
if date_x < datetime.datetime.now(): | |
print("Ошибка") | |
exit() | |
else: |
This file contains 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
def collatz(number): | |
global result | |
if number % 2 == 0: | |
result = number // 2 | |
return result | |
elif number % 2 == 1: | |
result = 3 * number + 1 | |
return result | |
try: |
This file contains 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
''' | |
Запятая в качестве разделителя | |
Предположим, у вас имеется список наподобие следующего: | |
spam = ['apples', 'bananas', 'tofu', 'cats'] | |
Напишите функцию, которая принимает список в качестве аргумента и возвращает строку, в которой | |
все элементы списка разделены запятой и пробелом, а перед последним элементом вставлено слово and. | |
Например, передав функции предыдущий список spam, вы должны получить строку 'apples, bananas, tofu, and cats'. | |
Но ваша функция должна работать с любыми списками. |
This file contains 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
"""From grid lists print this: | |
..OO.OO.. | |
.OOOOOOO. | |
.OOOOOOO. | |
..OOOOO.. | |
...OOO... | |
....O....""" | |
grid = [['.', '.', '.', '.', '.', '.'], | |
['.', 'O', 'O', '.', '.', '.'], |
This file contains 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
''' Вы создаете приключенческую видеоигру. Структурой данных для инвентаря должен быть словарь, в котором | |
ключи - это строковые значения, описывающие инвентарь, а значения - количество имеющихся у игрока единиц данного | |
инвентаря. | |
Напишите функцию displayInventory(), которая принимает в качестве аргумента описание любого 'инвентаря' и отображает | |
его примерно в следующем виде. | |
Inventory: | |
12 arrow | |
42 gold coin | |
6 torch |
This file contains 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
'''Задание - https://yapx.ru/v/HUSTz''' | |
from collections import Counter | |
inventory = {'rope': 1, 'torch': 6, 'gold coin': 42, 'dagger': 1, 'arrow': 12} | |
def add_to_inventory(base_inventory, added_items): | |
added_inventory = Counter(base_inventory) + Counter(added_items) | |
return added_inventory |
This file contains 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
"""Задание - https://yapx.ru/v/HV2wK""" | |
def print_table(your_table): | |
col_widths = [0] * len(your_table) | |
for i in range(len(col_widths)): | |
col_widths[i] = max(your_table[i], key=len) | |
for g in range(len(col_widths)): | |
col_widths[g] = len(col_widths[g]) | |
number = max(col_widths) |
This file contains 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
import re | |
numbersRegex = re.compile(r'''\d''') #Разделяем только по цифрам | |
numbersRegex2 = re.compile(r'''[a-zA-Z]''') #Разделяем по буквам | |
numbersRegex3 = re.compile(r'''([a-zA-Z0-9]+)''') #Разделяем на группы | |
result = numbersRegex.findall('q1/w2/e3/r4/t5/y6') | |
result2 = numbersRegex2.findall('q1/w2/e3/r4/t5/y6') | |
result3 = numbersRegex3.findall('q1/w2/e3/r4/t5/y6') |
This file contains 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
import re | |
numbers = ("12345678901,\n" | |
"12345678901,\n" | |
"34567990123,\n" | |
"45679901237,\n" | |
"46789012347,\n" | |
"17890123456,\n" | |
"99723877828,\n" | |
"13828392321\n") |
OlderNewer