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
| Проверь никнейм 👩🌶️ | |
| Во время собеседования вам предложили решить задачу на валидацию имени пользователя. Пользователь пытается создать никнейм для своего аккаунта в соцсети Y. Правила для корректного никнейма в соцсети Y следующие: | |
| никнейм должен начинаться с символа @ | |
| никнейм должен содержать от | |
| 5 | |
| 5 до | |
| 15 | |
| 15 (включительно) символов (включая первый символ @) | |
| никнейм должен содержать только строчные буквы и цифры (помимо первого символа @) |
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
| from random import choice | |
| HANGMAN = ( | |
| """ | |
| ------ | |
| | | | |
| | | |
| | | |
| | | |
| | |
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
| import random | |
| while True: # обратите внимание на эту строку кода | |
| user_action = input("Сделайте выбор — камень, ножницы или бумага: ") | |
| possible_actions = ["камень", "бумага", "ножницы"] | |
| computer_action = random.choice(possible_actions) | |
| print(f"\nВы выбрали {user_action}, компьютер выбрал {computer_action}.\n") | |
| if user_action == computer_action: | |
| print(f"Оба пользователя выбрали {user_action}. Ничья!!") | |
| elif user_action == "камень": | |
| if computer_action == "ножницы": |
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
| class Library: | |
| def __init__(self): | |
| self.book_storage = [] | |
| def add_book(self, book): | |
| self.book_storage.append(book) | |
| book.set_available(True) | |
| def remove_book(self, book): | |
| if book in self.book_storage: |
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
| """Create a function that takes an integer as an | |
| argument and returns "Even" for even numbers or | |
| "Odd" for odd numbers.""" | |
| def even_or_odd(number): | |
| return "Odd" if number % 2 != 0 else "Even" | |
| """ What if we need the length of the words separated by a |
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
| """ | |
| Найдите индексы первого вхождения максимального элемента. | |
| Выведите два числа: номер строки и номер столбца, | |
| в которых стоит наибольший элемент в двумерном массиве. | |
| Если таких элементов несколько, то выводится тот, у которого меньше номер строки, | |
| а если номера строк равны то тот, у которого меньше номер столбца. | |
| Программа получает на вход размеры массива n и m, затем n строк по m чисел в каждой. | |
| """ |
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
| # Создать класс Car; | |
| # С атрибутами make, model, year, color; | |
| # Создать пару методов для класса; | |
| # Создать несколько экземпляров класса; | |
| # Создать подкласс; | |
| # **(опционально)Создать счетчик для количества созданных объектов класса. | |
| class Car: | |
| counter = 0 | |
| def __init__(self, mark, model, year, color) -> None: |
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
| # Создайте python файл prepare.py; | |
| # • Внутри него напишите код для: | |
| # 1. Создания папки 'backups' на рабочем столе; | |
| # 2. Создания файлов которые называются 'db_backup_2023_01_01.txt' внутри | |
| # папки 'backups' для дат с 1го октября до вчерашнего дня; | |
| import os | |
| from datetime import datetime |
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
| """ Написать функцию которая решает дискриминант(Даны коэфиценты: a, b, c);""" | |
| # D = b**2 - 4 a*c | |
| from math import pow, floor | |
| def disc(a, b, c): | |
| D = pow(b, 2) - 4 * a * c | |
| return D |
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
| """ | |
| Есть два списка с числами одного размера. | |
| Нужно найти сумму всех соответсвующих чисел; с помощью map | |
| """ | |
| lst1 = [1, 3, 5, 7] | |
| lst2 = [2, 4, 6, 8] | |
| def sum_of_lists(lst1, lst2): |
NewerOlder