├── BirthdaySaver ├── EbayScrape ├── FinanceCalculator ├── FizzBuzz ├── IP to binary IP ├── PinCracker └── README.md /BirthdaySaver: -------------------------------------------------------------------------------- 1 | birthdays = {'Snoopy' : '02/11/1947', 'Donald' : '04/16/1957'} 2 | 3 | while True: 4 | 5 | print ('Name the birhday you wish to recall.') 6 | 7 | name = input() 8 | 9 | if name in birthdays: 10 | 11 | print(name + ' has a birthday on ' + birthdays[name]) 12 | 13 | else: 14 | 15 | print('This name has not been entered into the database.') 16 | 17 | print('What is their birthdate?') 18 | 19 | birth = input() 20 | 21 | print(name + ' Has a birthday of ' + birth + ', this has been entered into the database.') 22 | 23 | birthdays[name] = birth 24 | -------------------------------------------------------------------------------- /EbayScrape: -------------------------------------------------------------------------------- 1 | #! python3 2 | import requests as r 3 | from bs4 import BeautifulSoup as bs 4 | import webbrowser as w 5 | c = 0#this is a counter for looping through the URL's in the list 6 | li = []#records links to gaggia so that no repeats come up 7 | URL = ['Put url here', 'here', 'and here'] 8 | for i in URL:#This cycles through the URL's 9 | page = r.get(URL[c]) 10 | c+=1 11 | soup = bs(page.content, "html.parser") 12 | searc = soup.find(id="srp-river-main")#This selects all info on the page 13 | gaggia = searc.find_all("div", class_="s-item__info clearfix") #this defines the information for each item on the page 14 | g = 0 #this is useless but I needed put someting in the if statements below 15 | for i in gaggia: 16 | itemname = i.find("h3", class_= "s-item__title") 17 | price = i.find("span", class_= "s-item__price") 18 | link = i.find("a", class_= "s-item__link") 19 | x = 'gaggia' and 'classic' 20 | y = 'to' 21 | if link["href"] not in li: 22 | if x in itemname.text.lower(): 23 | if price == None: 24 | g+=1 25 | elif y in price.text.replace('$' ,''): 26 | g+=1 27 | elif (float(price.text.replace('$','').replace(',','')) <= 200) and (float(price.text.replace('$','').replace(',','')) >=70): 28 | print (itemname.text, end = "\n") 29 | print (price.text, end = "\n") 30 | li.append(link["href"]) 31 | w.open(link["href"]) 32 | -------------------------------------------------------------------------------- /FinanceCalculator: -------------------------------------------------------------------------------- 1 | from decimal import Decimal 2 | 3 | #Defines our dictionaries 4 | F = {} 5 | M = {} 6 | 7 | #This chunk builds the F dictionary 8 | print ('Enter your annual income') 9 | n=input() 10 | F['Income'] = n 11 | print ('Enter your current savings') 12 | n=input() 13 | F['Savings'] = n 14 | print ('Enter your current stock investments') 15 | n=input() 16 | F['In_Stocks'] = n 17 | print ('Enter the rate of return(%)') 18 | n=input() 19 | F['Rate_of_return'] = n 20 | print ('How much do you invest monthly?') 21 | n=input() 22 | F['Monthly_investment'] = n 23 | 24 | print ("\n" + 'Please list all the monthly payments you can think of. When you are done with your list type EXIT', "\n") 25 | 26 | #makes a loop where you can enter your monthly expenses 27 | while True: 28 | print ('Item:') 29 | Mon = input() 30 | if Mon == 'EXIT': 31 | break 32 | else: 33 | print ('Cost:') 34 | cost = input() 35 | M[Mon]=int(cost) 36 | 37 | #This chunk prints a list of monthly expenses 38 | print (' ') 39 | print ('Here are your monthly expenses:') 40 | for key, value in M.items(): 41 | print (key + ':' + str(value)) 42 | print ('In total that is: ' + str(sum(M.values())) + "\n") 43 | 44 | #This is a chunk of code that lists investment stats 45 | print ('Here are your investments/income:') 46 | for key, value in F.items(): 47 | print (key + ':' + str(value)) 48 | IIAY = int((F.get('Monthly_investment')))*12 49 | print ('Your total yearly investments are: '+ str(IIAY)) #Stands for investments in a year 50 | 51 | # Prints the income you get at the end of a certain time 52 | print ("\n" + 'Enter the time you want projected') 53 | tim = input() 54 | incomeproj = int(F.get('Income', value)) * int(tim) 55 | print ("\n" + 'Net income made in ' + str(tim) + ' years: ' + str(incomeproj)) 56 | 57 | #Subtracts expenses 58 | MME = int(incomeproj) -(int(IIAY) * int(tim)) - ((int(sum(M.values())) * 12 )* int(tim)) 59 | print ('Minus your monthly expenses and investments for those years: '+ str(MME)) 60 | 61 | #Finds the money after x years given current rate of return, monthly investments, and current money in investments 62 | IAXY = (int(F.get('In_Stocks', value)) + (int(IIAY) * int(tim))) #Investments After X Years 63 | IAXYAG = ((Decimal(IAXY) * (Decimal(F.get('Rate_of_return', value))/100) + Decimal(IAXY))) #Investments After X Years And Growth 64 | print('This is how much you will have in stocks after those years of investing: ' + str(IAXY)) 65 | print('This is how much you will have in stocks after those years of investing plus the return: ' + str((IAXYAG))) 66 | 67 | #Calculates an estamated net worth 68 | Bleep = int(IAXYAG) + int(MME) 69 | print ("\n" + 'Assuming you only spend money on your montly expenses your net worth is: ' + str(Bleep)) 70 | print ('That means your rate of net growth since ' + str(tim) + ' years ago is: ' + str(Bleep /(int(F.get('Savings', value))))+ '%') 71 | 72 | #Calculates when you can retire 73 | print ("\n"+'Would you like to calculate when you can retire based on this information? Yes or No?'+ '\n') 74 | n = input() 75 | if n == 'Yes': 76 | 77 | print ('How much do you expect to spend monthly after retirement?' + '\n') 78 | Monthly = input() 79 | Yearly = (int(Monthly) * 12) 80 | fourper = (Yearly * 25) 81 | print ('This means that each year you will need ' + str(Yearly)) 82 | print ('The 4% rule says you will need ' + str(fourper) + ' to retire at this monthly cost.') 83 | numyears = fourper / (Bleep/int(tim)) 84 | print ('It will take you ' + str(numyears) + ' years to retire.') 85 | 86 | elif n == 'No': 87 | Break() 88 | -------------------------------------------------------------------------------- /FizzBuzz: -------------------------------------------------------------------------------- 1 | for i in range(101): 2 | 3 | if i % 3 == 0 and i % 7 == 0: 4 | 5 | print('FizzBuzz') 6 | 7 | elif i % 3 == 0: 8 | 9 | print('Fizz') 10 | 11 | elif i % 7 == 0: 12 | 13 | print('Buzz') 14 | 15 | else: 16 | 17 | print (i) 18 | 19 | -------------------------------------------------------------------------------- /IP to binary IP: -------------------------------------------------------------------------------- 1 | #This collects the IP and prints it 2 | print ('Enter the IP one byte at a time') 3 | A = [] #To store the IP 4 | count = 0 # begins the counter to show the byte entered 5 | for i in range(4): 6 | count += 1 7 | IP = int(input('Enter byte ' + str(count) + ': ')) 8 | A.append(IP) 9 | print ('Your IP is: ' + str(A[0]) + '.' + str(A[1]) + '.' + str(A[2]) + '.' + str(A[3])) 10 | 11 | c = []#to store the binary ip 12 | #this converts to binary 13 | def binaryip(b): 14 | x = -1 15 | y = -1 16 | for i in range(4): 17 | x += 1 18 | y += 1 19 | if (b[x]) >= 128: 20 | b[x] = b[x] - 128 21 | c.append(1) 22 | else: 23 | c.append(0) 24 | if (b[x]) >= 64: 25 | b[x] = b[x] - 64 26 | c.append(1) 27 | else: 28 | c.append(0) 29 | if (b[x]) >= 32: 30 | b[x] = b[x] - 32 31 | c.append(1) 32 | else: 33 | c.append(0) 34 | if (b[x]) >= 16: 35 | b[x] = b[x] - 16 36 | c.append(1) 37 | else: 38 | c.append(0) 39 | if (b[x]) >= 8: 40 | b[x] = b[x] - 8 41 | c.append(1) 42 | else: 43 | c.append(0) 44 | if (b[x]) >= 4: 45 | b[x] = b[x] - 4 46 | c.append(1) 47 | else: 48 | c.append(0) 49 | if (b[x]) >= 2: 50 | b[x] = b[x] - 2 51 | c.append(1) 52 | else: 53 | c.append(0) 54 | if (b[x]) >= 1: 55 | b[x] = b[x] - 1 56 | c.append(1) 57 | else: 58 | c.append(0) 59 | c.append('.') 60 | 61 | binaryip(A) 62 | 63 | print('The binary IP is: ', end="") 64 | print (*c[0:35], sep = '') 65 | -------------------------------------------------------------------------------- /PinCracker: -------------------------------------------------------------------------------- 1 | import random as r 2 | import string 3 | import time as t 4 | 5 | #must enter 4 digit num/letter 6 | C = str(input('Please enter a 4 digit password, it can consist of numbers and letters only: ')) 7 | st = t.time() 8 | password = C 9 | X = 0 10 | H = 0 11 | def some(e): 12 | w = r.randint(0,5) 13 | if w in [1, 5]: 14 | return(r.randint(0, 9)) 15 | else: 16 | return(r.choice(string.ascii_letters)) 17 | while (X)!= str(password): 18 | X = str(some(1)) + str(some(1)) +str(some(1)) + str(some(1)) 19 | print(X) 20 | H += 1 21 | en = t.time() 22 | elsa = (en - st) 23 | m, s = divmod(elsa, 60) 24 | print (f'It took {int(m)} minutes and {int(s)} seconds to crack this password.' ) 25 | print(f'It took you {H:,} iterations to get the password.') 26 | print('The password was: ' + str(X)) 27 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # LearningStuff 2 | This is my repository for learning Python. 3 | I will post my programs as I learn to code in Python. 4 | --------------------------------------------------------------------------------