Skip to main content

Compute all the Permutation of a String

May 31, 2023CodeCatch
Loading...

More Python Posts

bruteforce password cracker

Nov 18, 2022AustinLeath

0 likes • 0 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()))

Plotting Fibonacci

Nov 19, 2022CodeCatch

0 likes • 0 views

# Python program for Plotting Fibonacci
# spiral fractal using Turtle
import turtle
import math
def fiboPlot(n):
a = 0
b = 1
square_a = a
square_b = b
# Setting the colour of the plotting pen to blue
x.pencolor("blue")
# Drawing the first square
x.forward(b * factor)
x.left(90)
x.forward(b * factor)
x.left(90)
x.forward(b * factor)
x.left(90)
x.forward(b * factor)
# Proceeding in the Fibonacci Series
temp = square_b
square_b = square_b + square_a
square_a = temp
# Drawing the rest of the squares
for i in range(1, n):
x.backward(square_a * factor)
x.right(90)
x.forward(square_b * factor)
x.left(90)
x.forward(square_b * factor)
x.left(90)
x.forward(square_b * factor)
# Proceeding in the Fibonacci Series
temp = square_b
square_b = square_b + square_a
square_a = temp
# Bringing the pen to starting point of the spiral plot
x.penup()
x.setposition(factor, 0)
x.seth(0)
x.pendown()
# Setting the colour of the plotting pen to red
x.pencolor("red")
# Fibonacci Spiral Plot
x.left(90)
for i in range(n):
print(b)
fdwd = math.pi * b * factor / 2
fdwd /= 90
for j in range(90):
x.forward(fdwd)
x.left(1)
temp = a
a = b
b = temp + b
# Here 'factor' signifies the multiplicative
# factor which expands or shrinks the scale
# of the plot by a certain factor.
factor = 1
# Taking Input for the number of
# Iterations our Algorithm will run
n = int(input('Enter the number of iterations (must be > 1): '))
# Plotting the Fibonacci Spiral Fractal
# and printing the corresponding Fibonacci Number
if n > 0:
print("Fibonacci series for", n, "elements :")
x = turtle.Turtle()
x.speed(100)
fiboPlot(n)
turtle.done()
else:
print("Number of iterations must be > 0")

Finding NULL values within set

Oct 7, 2022KETRICK

0 likes • 1 view

x[cat_var].isnull().sum().sort_values(ascending=False)

Untitled

Apr 21, 2023sebastianagauyao2002-61a8

0 likes • 0 views

print("hellur")

Delete all even numbers

Nov 19, 2022CodeCatch

0 likes • 0 views

# Deleting all even numbers from a list
a = [1,2,3,4,5]
del a[1::2]
print(a)

Print pyramid pattern

Nov 19, 2022CodeCatch

0 likes • 0 views

def print_pyramid_pattern(n):
# outer loop to handle number of rows
# n in this case
for i in range(0, n):
# inner loop to handle number of columns
# values changing acc. to outer loop
for j in range(0, i+1):
# printing stars
print("* ",end="")
# ending line after each row
print("\r")
print_pyramid_pattern(10)