find parity outliers

0 likes • Nov 19, 2022 • 0 views
Python

More Python Posts

0 likes • Nov 18, 2022 • 0 views
Python
```import itertoolsimport stringimport 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()))```

Calculator

0 likes • Nov 19, 2022 • 0 views
Python
`""" Calculator----------------------------------------"""def addition ():    print("Addition")    n = float(input("Enter the number: "))    t = 0 //Total number enter    ans = 0    while n != 0:        ans = ans + n        t+=1        n = float(input("Enter another number (0 to calculate): "))    return [ans,t]def subtraction ():    print("Subtraction");    n = float(input("Enter the number: "))    t = 0 //Total number enter    sum = 0    while n != 0:        ans = ans - n        t+=1        n = float(input("Enter another number (0 to calculate): "))    return [ans,t]def multiplication ():    print("Multiplication")    n = float(input("Enter the number: "))    t = 0 //Total number enter    ans = 1    while n != 0:        ans = ans * n        t+=1        n = float(input("Enter another number (0 to calculate): "))    return [ans,t]def average():    an = []    an = addition()    t = an[1]    a = an[0]    ans = a / t    return [ans,t]// main...while True:    list = []    print(" My first python program!")    print(" Simple Calculator in python by Malik Umer Farooq")    print(" Enter 'a' for addition")    print(" Enter 's' for substraction")    print(" Enter 'm' for multiplication")    print(" Enter 'v' for average")    print(" Enter 'q' for quit")    c = input(" ")    if c != 'q':        if c == 'a':            list = addition()            print("Ans = ", list[0], " total inputs ",list[1])        elif c == 's':            list = subtraction()            print("Ans = ", list[0], " total inputs ",list[1])        elif c == 'm':            list = multiplication()            print("Ans = ", list[0], " total inputs ",list[1])        elif c == 'v':            list = average()            print("Ans = ", list[0], " total inputs ",list[1])        else:            print ("Sorry, invilid character")    else:        break`

Caesar Encryption

0 likes • Mar 10, 2021 • 0 views
Python
```import string
def caesar(text, shift, alphabets):	def shift_alphabet(alphabet):	    return alphabet[shift:] + alphabet[:shift]		shifted_alphabets = tuple(map(shift_alphabet, alphabets))	final_alphabet = "".join(alphabets)	final_shifted_alphabet = "".join(shifted_alphabets)	table = str.maketrans(final_alphabet, final_shifted_alphabet)	return text.translate(table)
plain_text = "Hey Skrome, welcome to CodeCatch"print(caesar(plain_text, 8, [string.ascii_lowercase, string.ascii_uppercase, string.punctuation]))```

curry function

0 likes • Nov 19, 2022 • 1 view
Python
```from functools import partial

Print "X" pattern

0 likes • Nov 19, 2022 • 0 views
Python
```def print_x_pattern(size):    i,j = 0,size - 1
while j >= 0 and i < size:
initial_spaces = ' '*min(i,j)        middle_spaces = ' '*(abs(i - j) - 1)        final_spaces = ' '*(size - 1 - max(i,j))
if j == i:            print(initial_spaces + '*' + final_spaces)        else:            print(initial_spaces + '*' + middle_spaces + '*' + final_spaces)
i += 1        j -= 1
print_x_pattern(7)```

Hello World

0 likes • Sep 9, 2023 • 11 views
Python
`print("test")`