Skip to content

Instantly share code, notes, and snippets.

View reloadedd's full-sized avatar
💭
Stackin' up

ʀᴇʟᴏᴀᴅᴇᴅᴅ ⌞⌯⌝ reloadedd

💭
Stackin' up
View GitHub Profile
#!/usr/bin/env python3
WORD = 'EVAPORATE'
if __name__ == '__main__':
guessed = False
build_word = list('_' * len(WORD))
print('>>> Welcome to Hangman!')
print('_ ' * len(WORD))
#!/usr/bin/env python3
from random import choice
def pick_random_word(wordlist: list) -> str:
"""Pick a random number from a list of words."""
return choice(wordlist)
#!/usr/bin/env python3
from sys import exit
BOARD_SIZE = 3
BOARD = [['0', '0', '0'],
['0', '0', '0'],
['0', '0', '0']]
SCORE = {'player_one': 0, 'player_two': 0}
#!/usr/bin/env python3
def max_of_three(first: int, second: int, third: int) -> int:
"""This function returns the maximum number out of three numbers."""
if first > second:
if first > third:
return first
return third
#!/usr/bin/env python3
def check_win(board: list) -> int:
"""This function takes a board in form of a matrix aka a list of a list and
checks whether any player has won the game."""
# Check if someone has won - line
for row in board:
if (row[0] == row[1] == row[2]) and (row[0] != 0):
#!/usr/bin/env python3
def binary_search() -> None:
left = 0
right = 100
guesses = 0
while left <= right:
guesses += 1
#!/usr/bin/env python3
def create_line(columns: int) -> None:
"""This function draws a line full of character "squares"."""
print(' ---' * columns, sep='')
print('| ' * columns, '|', sep='')
#!/usr/bin/env python3
def create_list_from_file(filename: str) -> list:
"""This function creates a list of all the numbers from the file given as
argument to the function. It then returns the list.
"""
numbers = []
with open(filename) as file:
#!/usr/bin/env python3
if __name__ == '__main__':
filename = 'Training_01.txt'
with open(filename) as sun_pictures:
categories = {}
line = sun_pictures.readline()
while line:
#!/usr/bin/env python3
import requests
from bs4 import BeautifulSoup
if __name__ == '__main__':
responseObj = requests.get('https://www.nytimes.com/')
soup = BeautifulSoup(responseObj.text, 'html.parser')
filename = input('Write the name of the file in which to write the '