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
| # Разобраться в коде unit_test_framework.py | |
| # Напишете интерактивный калькулятор. | |
| # Предполагается, что пользовательский ввод представляет собой формулу, | |
| # состоящую из числа, оператора (как минимум + и -) и другого числа, | |
| # разделенных пробелом (например, 1 + 1). Используйте str.split () | |
| # Если входные данные не состоят из 3 элементов, генерируйте эксепшн FormulaError. | |
| # Попробуйте преобразовать первый и третий элемент в float | |
| # ( float_value = float(str_value)). | |
| # Поймайте любую возникающую ValueError и сгенерируйте вместо него FormulaError | |
| # Если второй элемент не является «+» или «-», киньте эксепшн FormulaError |
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
| # pip install prettytable | |
| from prettytable import PrettyTable | |
| resultTable = PrettyTable() | |
| class Homework: | |
| def __init__(self, name, description, complexity, status): | |
| self.name = name | |
| self.description = description |
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
| # bad | |
| user = {"first_name": "John", "last_name": "Doe"} | |
| full_name = f"{user['first_name']} {user['last_name']}" | |
| # better | |
| class User: | |
| def __init__(self, first_name, last_name): | |
| self.first_name = first_name |
OlderNewer