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
| def binary_search(sequence, find_elem): | |
| end_element = len(sequence) - 1 | |
| start_element = 0 | |
| while start_element <= end_element: | |
| middle_element = start_element + (end_element - start_element) // 2 | |
| if sequence[middle_element] == find_elem: | |
| return middle_element | |
| elif sequence[middle_element] < find_elem: | |
| start_element = middle_element + 1 | |
| else: |
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
| def persen(mass1, mass2): | |
| avg_mass1 = sum(mass1)/len(mass1) | |
| avg_mass2 = sum(mass2)/len(mass2) | |
| a1 = [x - avg_mass1 for x in mass1] | |
| a2 = [x - avg_mass2 for x in mass2] | |
| psum = sum(xi * yi for xi, yi in zip(a1, a2)) | |
| aa1 = [pow(x - avg_mass1, 2) for x in mass1] |
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
| def input_coord(): | |
| index_x = int(input("Введите х координату: ")) | |
| index_y = int(input("Введите y координату: ")) | |
| return index_x, index_y | |
| def hod_x(mass): | |
| while True: | |
| x, y = input_coord() | |
| if check_hod(mass, x, y): |
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
| def sort_list_imperative(numbers: list) -> list: | |
| for i in range(len(numbers)-1): | |
| for j in range(len(numbers)-1-i): | |
| if numbers[j] > numbers[j+1]: | |
| numbers[j], numbers[j+1] = numbers[j+1], numbers[j] | |
| return numbers | |
| def sort_list_declarative(numbers: list) -> list: | |
| return sorted(numbers) |
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
| numbers = [2, 5, 13, 7, 6, 4] | |
| size = 6 | |
| sum = 0 | |
| avg = 0 | |
| index = 0 | |
| while index < size: | |
| sum = sum + numbers[index] | |
| index = index + 1 | |
| avg = sum/size | |
| print("avg = ", avg) |
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 pytest | |
| def diff(first, second): | |
| len_diff = len(first) - len(second) | |
| if abs(len_diff) > 1: | |
| return False | |
| if len_diff > 0: | |
| short_str = second | |
| long_str = first |
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
| def p(func): | |
| def new_func(*args, **kwargs): | |
| ret = func(*args, **kwargs) | |
| print(ret) | |
| return ret | |
| return new_func | |
| ###############################33 |
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 funcy | |
| import requests | |
| import aiohttp | |
| import asyncio | |
| import concurrent.futures | |
| pages = ["https://yandex.ru", "https://google.com", "http://selectel.ru"] | |
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
| # coding: utf-8 | |
| from flask import Flask, request, jsonify | |
| import os | |
| import logging | |
| app = Flask(__name__) | |
| download_folder = "./download/" | |
| from database import DB_CONNECTOR, ORM | |
| from flask.ext.login import LoginManager | |
| import flask.ext.login as flask_login |
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
| parser = argparse.ArgumentParser() | |
| parser.add_argument('-f', '--folder', default = './') | |
| parser.add_argument('-l', '--login', default = '') | |
| parser.add_argument('-p', '--password', default = '') | |
| parser.add_argument('-s', '--save', default = 'server') | |
| namespace = parser.parse_args() | |
| save_data = namespace.save | |
| print "how save file = ", save_data | |
| if save_data == "cloud": |
NewerOlder