Summation Calculator

This code can add all integers, between 2 distinct integers, including negative integers, in increments of your choice, no matter which order the distinct integers are places in.

import math print("Welcome to the summation calculator") a = int(input("Please enter first number")) b = int(input("Please enter second number")) c = int(input("Please enter what increments to skip count by")) if a > b and c >= a: print("Sorry, your increment is not valid") elif b > a and c >= b: print("Sorry, your increment is not valid") elif a == b: print("Sorry, your values are equal") elif a > b: d = int(sum(range(b, a, c))) print(d) elif b > a: g = int(sum(range(a, b, c))) print(g)

2 Number Calculator

This code will allow you to use many operations with 2 numbers, not just the 4 basic operations!

print("Please insert two numbers and what you want to do with them") a = float(input("Please enter Number a here")) b = float(input("Please enter Number b here")) Operation = input("Please enter operation here. Please use the words Addition, Subtraction, Division, Multiplication, " "Square Root of a, Square Root of b, a choose b, b choose a,\n a to the power of b, and b to the" "power of a. If you don't want 2 numbers, please enter a random number in that slot. Thank you.") if Operation == "Addition": print(a+b) elif Operation == "Subtraction": print(a-b) elif Operation == "Division": print(a/b) elif Operation == "Multiplication": print(a*b) elif Operation == "a choose b": c = math.comb(int(a), int(b)) print(c) elif Operation == "b choose a": d = math.comb(int(b), int(a)) print(d) elif Operation == "a to the power of b": g = pow(int(a), int(b)) print(g) elif Operation == "b to the power of a": h = math.comb(int(b), int(a)) print(h) elif Operation == "Square root of a": j = math.sqrt(int(a)) print(j) elif Operation == "Square root of b": k = math.sqrt(int(b)) print(k) else: print("The operation given is not valid. Please try again.")

Regular Polygon and Circle Area Calculator

This will allow you to find the approximate area of several regular polygons and circles.

import math a = float(input("Please enter what regular polygon you want to find the area of. Options area a circle, equilateral " "triangle, square, pentagon, hexagon, octagon")) b = float(input("Please enter side length or radius of your polygon")) if a == "circle": print(3.1415 * b * b) elif a == "triangle": print(b * b * 0.433) elif a == "square": print(b * b) elif a == "pentagon": print(1.72 * b * b) elif a == "hexagon": print(2.598 * b * b) elif a == "octagon": print(4.828 * b * b) else: print("Sorry, either your polygon or length/radius is wrong")

Triangle Checker

This code will allow you to find if your triangle is equilateral, isosceles, scalene, acute, obtuse, or/and right!

Angle_A = float(input("Please enter value for angle 1 of a triangle")) Angle_B = float(input("Please enter value for angle 2 of b triangle")) Angle_C = float(input("Please enter value for angle 3 of c triangle")) if Angle_A + Angle_B + Angle_C != 180: print("Sorry, the angles you entered are not valid, please try again.") elif Angle_A > 90 or Angle_B > 90 or Angle_C > 90: print("Your triangle is Obtuse") elif Angle_A == 90 or Angle_B == 90 or Angle_C == 90: print("Your triangle is a Right triangle") elif Angle_A < 90 and Angle_B < 90 and Angle_C < 90: print("Your triangle is acute") elif Angle_A == Angle_B or Angle_B == Angle_C or Angle_A == Angle_C: print("Your triangle is isosceles") elif Angle_A != Angle_B != Angle_C: print("Your triangle is scalene") elif Angle_A == Angle_B == Angle_C: print("Your triangle is equilateral")

Currency Converter

This is a currency converter that includes USD, Pound, Euro, Rupee, and Yen. It was made using pyqt5.

This is a user-friendly Hangman game. I was working on it for three weeks.

https://repl.it/@BYLDOG/hangman
print("Starting a game of Hangman.") from random import randint valid1 = 0 x = 0 hg = 0 valid2 = 0 valid27000 = [ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z" ] valid30 = [ "1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "14", "15", "16", "17", "18", "19", "20", "21", "22", "23", "24", "25" ] valid900 = ["3", "4", "5", "6", "7", "8", "9", "10"] allwords = [ "dog", "cat", "man", "woman", "drums", "cousin", "brother", "epidemic", "pencilcase" ] y = len(allwords) validwords = [] while valid1 == 0: attempts = input("How many incorrect attempts do you want? [1-25] ") if attempts not in valid30: print("Not a valid number from 1 to 25") else: valid1 = 1 attempts = int(attempts) while valid2 == 0: minlen = input("What's the minimum length of the word? [3-10] ") if minlen not in valid900: print("Not a valid number from 3 to 10") else: valid2 = 1 minlen = int(minlen) while x in range(-1, y - 1): x = x + 1 lenx = int(len(allwords[x])) valid3 = max(lenx, minlen) if valid3 == lenx: validwords.append(allwords[x]) wordnm = randint(0, len(validwords) - 1) word = validwords[wordnm] wordlen = len(word) guess = [] wordlist = [] for x in range(0, wordlen): x = x + 1 guess.append("*") wordlist.append(word[x - 1]) while attempts > 0: print(guess) guess1 = input("Enter your guess: ") if guess1 not in valid27000: print( "This is not a valid guess. Try inputting a lowercase English letter" ) else: if guess1 not in wordlist: if attempts != 1: print("This letter is not in the word. Try again") else: print( "This letter is not in the word. You have ran out of attempts." ) attempts = attempts - 1 else: print("This letter is in the word") while hg in range(0, len(wordlist)): if wordlist[hg] == guess1: guess[hg] = guess1 hg = hg + 1 if guess == wordlist: print("You won! Congrats. The word is " + word) while True: aohuni = 1 hg = 0

Update For Code On Web Scraper

I accidentally forgot to include a filter for prices, here's the updated code.

""" Copyright Adam Blumenfeld All rights reserved """ # These are the variable you have to set Email = "email@example.com" Password = "examplepassword" # Imports import requests from bs4 import BeautifulSoup import smtplib import time import datetime import keyboard as k import sys wait = True def wait_false(): global wait wait = False k.add_hotkey("ctrl+g", lambda: wait_false()) # URLS you want to check URLS = ["https://www.amazon.com/Lysol-Bathroom-Cleaner-Island-Breeze/dp/B06ZZQSH77/ref=sr_1_5?dchild=1&keywords=lysol+spray&qid=1588110272&sr=8-5", "https://www.amazon.com/Lysol-Disinfectant-Spray-Morning-Breeze/dp/B01IAIMYF2/ref=sr_1_1?dchild=1&keywords=lysol+disinfectant&qid=1588133936&sr=8-1", "https://www.amazon.com/Scott-67805-Recycled-Bathroom-Tissue/dp/B0040ZOIZO/ref=pd_ybh_a_5?_encoding=UTF8&psc=1&refRID=Y73XTT0K4CR1PQMFPV3V", "https://www.amazon.com/AmScope-120X-1200X-M30-ABS-KT2-W-Beginner-Microscope/dp/B00GGY85EC/ref=sr_1_1?dchild=1&keywords=microscope&qid=1588207972&s=industrial&sr=1-1"] # Time you want to space out already made emails (If you want to never relese emails on an item again, set it to float('inf')) cooldown_time = 7200 headers = { "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36'} def check(URL, maillist): page = requests.get(URL, headers=headers) soup1 = BeautifulSoup(page.content, 'html.parser') soup = BeautifulSoup(soup1.prettify(), "html.parser") title = soup.find(id="productTitle").get_text().strip().split(',')[0] available = soup.find(id="availability") price = soup.find(id="priceblock_ourprice") if price != None: print("Product is available") send_mail(title, URL, maillist) return True if available == None: print("Product is available") send_mail(title, URL) return True available = available.findChild('span').get_text().strip()[0:15] if available == "Temporarily out": print("Product is available") send_mail(title, URL, maillist) return True print("Product isn't available") return False def send_mail(title, link, maillist): global email global password server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login(email, password) subject = f'"{title}" is available!' body = f'Check the Amazon link to see availablility: {link}' msg = f"Subject: {subject}\n\n{body}" server.sendmail( email, maillist, msg ) print('Email Has Been Sent!') server.quit() wait = True cooldown = {} # The time you want between checks time_between_checks = 120 while True: print("Press CTRL+g to fast forward check") i = 0 while i < time_between_checks and wait: time.sleep(1) print("Time since last check:", i, "\\", time_between_checks, end="\r") i += 1 wait = True print("\n") for URL in URLS: time_ = datetime.datetime.now() print(f"Checking... <{time_}> <{URL}>\n") if cooldown.get(URL) != None: if time.time() - cooldown[URL] >= cooldown_time: del cooldown[URL] else: print(f"Cooldown time for URL <{URL}>: {cooldown_time-int((time.time() - cooldown[URL]) % 60)} seconds") continue availability = check(URL, sys.argv) if availability: cooldown[URL] = time.time() print("\n\n")

Web Scraper For Amazon Availibility

This web scraper checks amazon links by URL every two minutes, and emails you when those products are available. There is a cooldown of 4 hours for products that have been found available and emailed to you, but this cooldown only affects the particular item and not all of the URLs. By the way these parameters are completely customizable (you can have your wait time be 5 minutes, your cooldown be infinite, etc.) I made this scraper to help people out with panic buying and the lowered availability of basic items. In my original program, I made an email called amazonbot100@gmail.com to carry out the emails. To set up an email with this program, here are the steps: 1. Create a new email (Recommended, but not required) 2. Enable two-factor authentication for your account (This is required for the next step) 3. Set up App Passwords for your account and create a new one for your computer. 4. Paste in the email address to the Email variable at the top, and paste the app password into the Password variable under that. 4.5. Search up "my user agent" on google and paste it into the user agent 5. Run python -m pip install bs4 6. Run python -m pip install requests 7. Run python -m pip install keyboard Also, I understand that the code isn't the most efficient, especially towards the end, though I was in a rush so don't judge me xD. Usage: python scraper.py email-to-send-1@example.com email-to-send-2@example.com email-to-send-3@example.com email-to-send-you-get-the-point@example.com

""" Copyright Adam Blumenfeld All rights reserved """ # These are the variable you have to set Email = "email@example.com" Password = "examplepassword" # Imports import requests from bs4 import BeautifulSoup import smtplib import time import datetime import keyboard as k import sys wait = True def wait_false(): global wait wait = False k.add_hotkey("ctrl+g", lambda: wait_false()) # URLS you want to check URLS = ["https://www.amazon.com/Lysol-Bathroom-Cleaner-Island-Breeze/dp/B06ZZQSH77/ref=sr_1_5?dchild=1&keywords=lysol+spray&qid=1588110272&sr=8-5", "https://www.amazon.com/Lysol-Disinfectant-Spray-Morning-Breeze/dp/B01IAIMYF2/ref=sr_1_1?dchild=1&keywords=lysol+disinfectant&qid=1588133936&sr=8-1", "https://www.amazon.com/Scott-67805-Recycled-Bathroom-Tissue/dp/B0040ZOIZO/ref=pd_ybh_a_5?_encoding=UTF8&psc=1&refRID=Y73XTT0K4CR1PQMFPV3V", "https://www.amazon.com/AmScope-120X-1200X-M30-ABS-KT2-W-Beginner-Microscope/dp/B00GGY85EC/ref=sr_1_1?dchild=1&keywords=microscope&qid=1588207972&s=industrial&sr=1-1"] # Time you want to space out already made emails (If you want to never relese emails on an item again, set it to float('inf')) cooldown_time = 7200 headers = { "User-Agent": 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/81.0.4044.113 Safari/537.36'} def check(URL, maillist): page = requests.get(URL, headers=headers) soup1 = BeautifulSoup(page.content, 'html.parser') soup = BeautifulSoup(soup1.prettify(), "html.parser") title = soup.find(id="productTitle").get_text().strip().split(',')[0] available = soup.find(id="availability") if available == None: print("Product is available") send_mail(title, URL) return True available = available.findChild('span').get_text().strip()[0:15] if available == "Temporarily out": print("Product is available") send_mail(title, URL, maillist) return True print("Product isn't available") return False def send_mail(title, link, maillist): global email global password server = smtplib.SMTP('smtp.gmail.com', 587) server.ehlo() server.starttls() server.ehlo() server.login(email, password) subject = f'"{title}" is available!' body = f'Check the Amazon link to see availablility: {link}' msg = f"Subject: {subject}\n\n{body}" server.sendmail( email, maillist, msg ) print('Email Has Been Sent!') server.quit() wait = True cooldown = {} # The time you want between checks time_between_checks = 120 while True: print("Press CTRL+g to fast forward check") i = 0 while i < time_between_checks and wait: time.sleep(1) print("Time since last check:", i, "\\", time_between_checks, end="\r") i += 1 wait = True print("\n") for URL in URLS: time_ = datetime.datetime.now() print(f"Checking... <{time_}> <{URL}>\n") if cooldown.get(URL) != None: if time.time() - cooldown[URL] >= cooldown_time: del cooldown[URL] else: print(f"Cooldown time for URL <{URL}>: {cooldown_time-int((time.time() - cooldown[URL]) % 60)} seconds") continue availability = check(URL, sys.argv) if availability: cooldown[URL] = time.time() print("\n\n")

Simple Imperial to Metric Converter//Temperature

This converter is written on Python and with it, you can convert any Fahrenheit measurement to Celsius.

https://repl.it/@BYLDOG/OldfashionedAquaOpen64
fdegrees=int(input("Enter the value in degrees Farenheit: ")) cdegrees1=fdegrees-32 cdegrees=cdegrees1/1.8 print("Your value in degrees Celsius is "+str(cdegrees))

Simple Metric to Imperial Converter//Weight

This converter is written on Python and with it, you can convert any metric measurement to pounds or ounces.

https://repl.it/@BYLDOG/RigidUnrealisticMacro
amount=int(input("How many? ")) msrmnt=input("What measurement(kg or g)? ") cvt=input("Convert to what(lb or oz)? ") if msrmnt=="kg": if cvt=="lb": print(amount*2.2) if cvt=="oz": print(amount*35.3) if msrmnt=="g": if cvt=="lb": print(amount/454) if cvt=="oz": print(amount/28)

Guessing Game

This is a Guessing game where you are supposed to use a while loop. In this game, While loops can be used to cycle through your code until you get the correct number.

Linear Regression with Multiple Variables


x = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10] y = [1, 4, 9, 16, 25, 36, 49, 64, 81, 100] z = [1, 8, 27, 64, 125, 216, 343, 512, 729, 1000] def SlopeD1(x, y, z, slope1, slope2, yInt): length = len(x) total = 0 for i in range(length): predicted = (slope1 * x[i]) + (slope2 * y[i]) + yInt difference = (z[i] - predicted) * x[i] total += difference returnValue = (-2/length) * total return returnValue def SlopeD2(x, y, z, slope1, slope2, yInt): length = len(x) total = 0 for i in range(length): predicted = (slope1 * x[i]) + (slope2 * y[i]) + yInt difference = (z[i] - predicted) * y[i] total += difference returnValue = (-2/length) * total return returnValue def InterceptD(x, y, z, slope1, slope2, yInt): length = len(x) total = 0 for i in range(length): predicted = (slope1 * x[i]) + (slope2 *y[1]) + yInt difference = (z[i] - predicted) total += difference returnValue = (-2/length) * total return returnValue m1 = 0 m2 = 0 c = 0 l = 0.000001 iterations = 99999 for i in range(iterations): mm1 = SlopeD1(x, y, z, m1, m2 ,c) mm2 = SlopeD2(x, y, z, m1, m2 ,c) yint = InterceptD(x, y, z, m1, m2 ,c) m1 = m1 - (l * mm1) m2 = m2 - (l * mm2) c = c - (l * yint) #print(m1, m2, c) print ('(', end ='' ) print(m1, end=', ') print(m2, end=', ') print(c, end=')')
1 2 ... 5