• Feb 23, 2025 •hasnaoui1
0 likes • 7 views
print("hello world")
• Jun 1, 2023 •CodeCatch
0 likes • 2 views
from colorama import init, Fore # Initialize colorama init() print(Fore.RED + "This text is in red color.") print(Fore.GREEN + "This text is in green color.") print(Fore.BLUE + "This text is in blue color.") # Reset colorama print(Fore.RESET + "This text is back to the default color.")
• Nov 19, 2022 •CodeCatch
0 likes • 16 views
def sum_of_powers(end, power = 2, start = 1): return sum([(i) ** power for i in range(start, end + 1)]) sum_of_powers(10) # 385 sum_of_powers(10, 3) # 3025 sum_of_powers(10, 3, 5) # 2925
• Nov 18, 2022 •AustinLeath
0 likes • 4 views
import itertools import string import time def guess_password(real): chars = string.ascii_lowercase + string.ascii_uppercase + string.digits + string.punctuation attempts = 0 for password_length in range(1, 9): for guess in itertools.product(chars, repeat=password_length): startTime = time.time() attempts += 1 guess = ''.join(guess) if guess == real: return 'password is {}. found in {} guesses.'.format(guess, attempts) loopTime = (time.time() - startTime); print(guess, attempts, loopTime) print("\nIt will take A REALLY LONG TIME to crack a long password. Try this out with a 3 or 4 letter password and see how this program works.\n") val = input("Enter a password you want to crack that is 9 characters or below: ") print(guess_password(val.lower()))
• Apr 15, 2021 •NoahEaton
0 likes • 0 views
import anytree as at import random as rm # Generate a tree with node_count many nodes. Each has a number key that shows when it was made and a randomly selected color, red or white. def random_tree(node_count): # Generates the list of nodes nodes = [] for i in range(node_count): test = rm.randint(1,2) if test == 1: nodes.append(at.Node(str(i),color="white")) else: nodes.append(at.Node(str(i),color="red")) #Creates the various main branches for i in range(node_count): for j in range(i, len(nodes)): test = rm.randint(1,len(nodes)) if test == 1 and nodes[j].parent == None and (not nodes[i] == nodes[j]): nodes[j].parent = nodes[i] #Collects all the main branches into a single tree with the first node being the root for i in range(1, node_count): if nodes[i].parent == None and (not nodes[i] == nodes[0]): nodes[i].parent = nodes[0] return nodes[0]
• Jan 20, 2021 •Ntindle
print(“Hello World”)