/
Carton
/
python-course-tasks
Обзор
Документация
Войти
/
Carton
/
python-course-tasks
Код
Запросы
0
Задачи
Вики
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
task_09_02_04/qreader/tuples.py
17 строк
570 B
Yuri Petrov
+ перенос заданий в отдельный репозиторий
02 июл 2020, 02:05
02 июл 2020, 02:05
5312992
Код
Авторство
О чём код?
__author__ = 'ewino' def add(t1, t_or_n): if isinstance(t_or_n, (int, float)): return tuple(x + t_or_n for x in t1) elif isinstance(t_or_n, tuple): return tuple(x + t_or_n[i] for i, x in enumerate(t1)) raise TypeError("Can't add a %s to a tuple" % type(t_or_n)) def multiply(t1, t_or_n): if isinstance(t_or_n, (int, float)): return tuple(x * t_or_n for x in t1) elif isinstance(t_or_n, tuple): return tuple(x * t_or_n[i] for i, x in enumerate(t1)) raise TypeError("Can't multiply a tuple by a" % type(t_or_n))