• Nov 18, 2022 •AustinLeath
0 likes • 5 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()))
• May 31, 2023 •CodeCatch
0 likes • 0 views
# Prompt user for a decimal number decimal = int(input("Enter a decimal number: ")) # Convert decimal to binary binary = bin(decimal) # Convert decimal to hexadecimal hexadecimal = hex(decimal) # Display the results print("Binary:", binary) print("Hexadecimal:", hexadecimal)
0 likes • 2 views
# Prompt user for base and height base = float(input("Enter the base of the triangle: ")) height = float(input("Enter the height of the triangle: ")) # Calculate the area area = (base * height) / 2 # Display the result print("The area of the triangle is:", area)
mydict = {'carl':40, 'alan':2, 'bob':1, 'danny':0} # How to sort a dict by value Python 3> sort = {key:value for key, value in sorted(mydict.items(), key=lambda kv: (kv[1], kv[0]))} print(sort) # How to sort a dict by key Python 3> sort = {key:mydict[key] for key in sorted(mydict.keys())} print(sort)
• Feb 23, 2025 •hasnaoui1
0 likes • 7 views
print("hello world")
• Nov 19, 2022 •CodeCatch
from collections import Counter def find_parity_outliers(nums): return [ x for x in nums if x % 2 != Counter([n % 2 for n in nums]).most_common()[0][0] ] find_parity_outliers([1, 2, 3, 4, 6]) # [1, 3]