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 get_user_int(msg): | |
| ''' | |
| Return integer from user. | |
| :param msg: | |
| :return user_input: | |
| ''' | |
| user_input = input(msg) | |
| try: | |
| user_input = int(user_input) | |
| except: |
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 get_list_ends(input_list): | |
| """ | |
| Return the first and last item of list. | |
| :param input_list: | |
| :return list_ends: | |
| """ | |
| return [input_list[0], input_list[-1]] | |
| a = [5, 10, 15, 20, 25] |
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 get_user_int(msg): | |
| ''' | |
| Return integer from user. | |
| :param msg: | |
| :return user_input: | |
| ''' | |
| user_input = input(msg) | |
| try: | |
| user_input = int(user_input) | |
| except: |
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 numpy | |
| def rnd_list(): | |
| size_of_list = numpy.random.randint(10, 20) | |
| return numpy.random.randint(0, 100, size_of_list) | |
| def rm_duplicates_1(lst): | |
| return list(set(lst)) |
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 string | |
| import random | |
| def generate(length=35, digits_count=5, upper_count=5, special_count=5): | |
| lower_count = max(0, length - digits_count - upper_count - special_count) | |
| digits = random.sample(string.digits, digits_count) | |
| specials = random.sample(string.punctuation, special_count) | |
| upper = random.sample(string.ascii_uppercase, upper_count) |
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 requests | |
| from bs4 import BeautifulSoup as bs | |
| url = "https://www.vanityfair.com/style/society/2014/06/monica-lewinsky-humiliation-culture" | |
| # get page and make soup for parsing | |
| soup = bs(requests.get(url).text, "html5lib") | |
| # select all tag p in tag section | |
| article = soup.select('section p') |
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 print_board(x, y): | |
| for i in range(y): | |
| print('+' + '---+'*x + '\n|' + ' |'*x) | |
| print('+' + '---+'*x) | |
| user = input("Size of board (XxY) -> ") | |
| user = user.split('x') | |
| x = int(user[0]) | |
| y = int(user[1]) |
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 check_ttt(game_list): | |
| # creating list that contain all possible lines in board | |
| # 8 lines = 3 horizontal + 3 vertical + 2 diagonal | |
| line_list = game_list | |
| line_list += list(zip(*game_list)) | |
| line_list += [[game_list[i][j] for i, j in zip(range(3), range(3))], | |
| [game_list[i][-j] for i, j in zip(range(3), range(1, 4))]] | |
| # calculate sum of each line if line have not nulls |
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 argparse import ArgumentParser | |
| from pathlib import Path | |
| from cv2 import waitKey | |
| from cv2 import imshow | |
| from cv2 import imread | |
| from cv2 import namedWindow | |
| from cv2 import setMouseCallback | |
| from cv2 import destroyAllWindows | |
| from cv2 import EVENT_LBUTTONUP |
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
| set nocompatible " be iMproved, required | |
| filetype off " required | |
| " set the runtime path to include Vundle and initialize | |
| set rtp+=~/.vim/bundle/Vundle.vim | |
| call vundle#begin() | |
| " alternatively, pass a path where Vundle should install plugins | |
| "call vundle#begin('~/some/path/here') | |
| " let Vundle manage Vundle, required |