Skip to content

Instantly share code, notes, and snippets.

@tdani6
tdani6 / password_generator
Created October 4, 2017 21:32
Write a password generator in Python. Be creative with how you generate passwords - strong passwords have a mix of lowercase letters, uppercase letters, numbers, and symbols. The passwords should be random, generating a new password every time the user asks for a new password. Include your run-time code in a main method.
import random
num=int(input('How long password do you want in characters?'))
char='qwertzuiopasdfghjklyxcvbnmQWERTZUIOPASDFGHJKLYXCVBNM<>#&@{}<'
password="".join(random.sample(char,num))
print('Your password is: '+ password)
@tdani6
tdani6 / cows_and_bulls.py
Created October 6, 2017 15:13
Create a program that will play the “cows and bulls” game with the user. The game works like this:
import random
solution=[]
for i in range(0,4):    solution.append(str(random.randint(0,9)))    print(solution[i])
#solution="".join(solution)print(solution)
guess=str(input('Make a guess'))
while guess != solution:            sol=solution    gu=guess    cows=0    bulls=0    counter=0
    for i in range(0,len(guess)):        print(guess[i])        if guess[i]==solution[i]:            cows+=1            del sol[i]            del gu[i]
    for k in len(gu):        for l in len(sol):            print(sol[l])            if gu[k]==sol[l]:                bulls+=1                del gu[k]                del sol[l]                k-=1                l-=1
print('You guessed the number, Congrats!')         
import random
print('''Hi! Welcome to the cows and bulls game. You have to figure out a 4 digit number.
For every digit you guess correctly in the correct place, you get a 'cow'. For every digit you guess correctly in the wrong place is a 'bull'.
Good luck, have fun!''')
solution=[]
for i in range(0,4):
solution.append(random.randint(0,9))
#print(solution[i])
guess=[]
@tdani6
tdani6 / binary_search
Created October 16, 2017 15:12
Write a function that takes an ordered list of numbers (a list where the elements are in order from smallest to largest) and another number. The function decides whether or not the given number is inside the list and returns (then prints) an appropriate boolean.
@tdani6
tdani6 / gist:6549416fb3d87168f8b71e36639f141e
Created November 15, 2017 16:40
HANGMAN - download SOWPODS and save it into SOWPODS.txt
import
random
 
with open ('SOWPODS.txt','r')
as f:
cols=int(input('How many columns do you want? '))
rows=int(input('How many rows do you want? '))
winnum=int(input('Please enter the victory threshold: '))
table=''
field=list()
def create_table(f,r,c): #make a function for table drawing
collist=list(range(1,c+1))
colstr='\t '