SAT/ ACT Scores

print ("This program compares two applicants") print ("Determine which one seems like the stronger applicant") y = int(input("(do you have 1) SAT scores 2) ACT scores?")) if y == 1: print ( " I will calculate your SAT score.") Math = int(input (" What is your SAT math score?")) Reading = int(input (" What is your Critical Reading score?")) Writing = int(input ("What is your Writing score?")) x = (2*Math+Reading+Writing)/32 print (x) OverallGPA= float(input("What is your overall GPA?")) MaxGPA = int(input("What is your max GPA?")) TranscriptMultiplier= float(input("What is your Transcript Multiplier?")) y= (OverallGPA/MaxGPA)*100*TranscriptMultiplier print (y) if y == 2: print ( "I will calculate your ACT score.") English= int(input (" What is your ACT english score?")) Math= int(input ("What is your ACT math score?")) Reading= int(input ("What is your ACT reading score? ")) Science= int(input ("What is your ACT science score? ")) t = (English+2*Math+Reading+Science)/1.8 print(t) actual = float(input (" What is your actual GPA score?")) Max = float(input (" What is your max GPA score?")) TranscriptMultiplier= float(input("What is your transcript multiplier?")) n= (actual/Max)*100*TranscriptMultiplier print(n)

homework/exam grade calculator

print:("This program read exam/homework scores and reports your overall course grade.") weight = int(input("Enter the weight:")) score= int(input("Score earned?")) scoreshifted=int(input("Were scores shifted")) if scoreshifted ==1: shiftAmount = int(input("Enter a shift amount: ")) score= score +shiftAmount print("totalscore = " + str(score) + "/ 100")

Guessing game

This is the code for the guessing game I'm making.

import random n = random.randint(1, 100) guess = int(input("Enter an integer from 1 to 99: ")) while n != ("guess"): print if guess < n: print("guess is low") guess = int(input("Enter an integer from 1 to 99: ")) elif guess > n: print("guess is high") guess = int(input("Enter an integer from 1 to 99: ")) else: print("you guessed it!") break print

AI Broken Down

This is one of my favorite videos describing math behind AI, specifically how a neural network is trained.


Grading Software

Here is a python program where you can input test grades and receive your overall score.

eight = int(raw_input("What is your weight")) ScoreEarned = int(raw_input("What is your score")) Extracredit = int(raw_input("Were scores shifted")) if Extracredit == 1: print("Your score was shifted") if Extracredit == 2: print("Your score was not shifted") totalpoints = (ScoreEarned) print("totalpoints = " + str(ScoreEarned) + " / 100") x = 100.0/ Weight weightedscore1 = ScoreEarned / x print(weightedscore1) print("This software will read your final test score") print(" Final:") Weight = int(raw_input("weight(1-100)?" )) ScoreEarned = int(raw_input("Score Earned?" )) Scoreshifted = int(raw_input("Were scores shifted (1=yes, 2= no)? ")) if Scoreshifted == 1: Amount= int(raw_input("By how much were they shifted?" )) totalpoints = ScoreEarned print("totalpoints= " + str(ScoreEarned) + " / 100") x = 100.0/Weight print(x) Weightedscore2 = ScoreEarned / x print(Weightedscore2) print("This software will read your homework grade") print("Homework:") Weight = int(raw_input("Weight(1-100)?")) Numofassignments = int(raw_input("Number of assignments?")) total = 0 totalpoints = 0 for i in range(1, Numofassignments+1, 1): Score = int(raw_input("What was your score for this assignment ?" + str(i))) total = total + Score Maxpoints = int(raw_input("What was the max score for this assignment ?" + str(i))) totalpoints = totalpoints + Maxpoints print("total points = " + str(total) + " / " + str(totalpoints)) percent = total / totalpoints wScore = percent * Weight print("Weightedscore3 = " + str(wScore) + " / " + str(Weight)) OverallPercentage = weightedscore1 + Weightedscore2 + wScore print(OverallPercentage)

python sorting program

a = [2, 3, 1, 7, 5, 4] min = 1000 index = -1 for start in range(0, len(a) - 1): min = 1000 for i in range(start, len(a)): if a[i] < min: min = a[i] index = i #swap temp = a[start]; a[start] = a[index]; a[index] = temp; print(a)

ACT or SAT

This code calculates ACT and SAT scores and GPA.

i= int(input("Do you have 1) SAT scores or 2) ACT scores?")) if i==1: Math=int(input("SAT math?")) Criticalreading= int(input("SAT reading")) Writing=int(input("SAT Writing")) X= (2*Math+Criticalreading+Writing)/32 print(X) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA1=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA1) elif i==2: English=int(input("ACT English")) Math=int(input("ACT math?")) Reading=int(input("ACT reading")) Science=int(input("ACT science")) Y= (English+2*Math+Reading+Science)/1.8 print(Y) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA2=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA2) i= int(input("Do you have 1) SAT scores or 2) ACT scores?")) if i==1: Math=int(input("SAT math?")) Criticalreading= int(input("SAT reading")) Writing=int(input("SAT Writing")) X= (2*Math+Criticalreading+Writing)/32 print(X) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA1=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA1) elif i==2: English=int(input("ACT English")) Math=int(input("ACT math?")) Reading=int(input("ACT reading")) Science=int(input("ACT science")) Y= (English+2*Math+Reading+Science)/1.8 print(Y) OverallGPA=float(input("What is your overall GPA?")) MaxGPA=float(input("What is the max GPA")) TranscriptMult=float(input("Transcript Multiplier?")) GPA2=OverallGPA/MaxGPA*100*TranscriptMult print("GPA score:") print(GPA2) Overallscore1=GPA1+X Overallscore2=GPA2+Y print("First applicant overall score:") print(Overallscore1wel) print("Second applicant overall score:") print(Overallscore2) if Overallscore1<Overallscore2: print("The first applicant seems to be better") if Overallscore1>Overallscore2: print("The second applicant seems to be better") if Overallscore1==Overallscore2: print("They are the same in value")

Fractions

this adds,subtracts,multiplies,divides fractions and returns the fraction

class Fraction: '''represents fractions''' def __init__(self,num,denom): self.num=num self.denom=denom '''Fraction(num,denom) -> Fraction creates the fraction object representing num/denom''' if denom == 0: # raise an error if the denominator is zero raise ZeroDivisionError def __str__(self): lst=[] if self.num == 0: return "0" if self.num<0: neg=-self.num for i in range(1,neg+1): if self.num/i==self.num//i and self.denom/i==self.denom//i: lst.append(-1*i) minimum=min(lst) smplfiednum=self.num//minimum smplfieddenom=self.denom//minimum return str(smplfiednum)+'/'+str(smplfieddenom) elif self.num>0: for n in range(1,self.num+1): if self.num/n==self.num//n and self.denom/n==self.denom//n: lst.append(n) maximum=max(lst) smplfiednum=self.num//maximum smplfieddenom=self.denom//maximum return str(smplfiednum)+'/'+str(smplfieddenom) def __float__(self): return self.num/self.denom def add(self, other): newdenom = self.denom*other.denom newnum = (self.num*other.denom)+(other.num*self.denom) #self.denom=newdenom #self.num=newnum return Fraction(newnum, newdenom) def sub(self, other): newdenom = self.denom*other.denom newnum = (self.num*other.denom)-(other.num*self.denom) #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def mul(self, other): newdenom = self.denom*other.denom newnum = self.num*other.num #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def div(self, other): newdenom = self.denom*other.num newnum = self.num*other.denom #self.denom=newdenom #self.num=newnum return Fraction(newnum,newdenom) def eq(self,other): if self.denom/other.denom==self.num/other.num: return True else: return False # examples #getting p p = Fraction(3,6) print(p) # should print 1/2 q = Fraction(10,-60) print(q) # should print -1/6 r = Fraction(-24,-48) print(r) # should also print 1/2 x=float(p) print(x) # should print 0.5 ### if implementing "normal" arithmetic methods print(p.add(q)) # should print 1/3, since 1/2 + (-1/6) = 1/3 print(p.sub(q)) # should print 2/3, since 1/2 - (-1/6) = 2/3 print(p.sub(p)) # should print 0/1, since p-p is 0 print(p.mul(q)) # should print -1/12 print(p.div(q)) # should print -3/1 print(p.eq(r)) # should print True print(p.eq(q)) # should print False

Password interpreter

The code checks a password to see if its meeting desired requirements.

def check_upper(input): uppers = 0 upper_list = "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".split() for char in input: if char in upper_list: uppers += 1 if uppers > 0: return True else: return False def check_lower(input): lowers = 0 lower_list = "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".split() for char in input: if char in lower_list: lowers += 1 if lowers > 0: return True else: return False def check_number(input): numbers = 0 number_list = "1 2 3 4 5 6 7 8 9 0".split() for char in input: if char in number_list: numbers += 1 if numbers > 0: return True else: return False def check_special(input): specials = 0 special_list = "! @ $ % ^ & * ( ) _ - + = { } [ ] | \ , . > < / ? ~ ` \" ' : ;".split() for char in input: if char in special_list: specials += 1 if specials > 0: return True else: return False def check_len(input): if len(input) >= 8: return True else: return False def validate_password(input): check_dict = { 'upper': check_upper(input), 'lower': check_lower(input), 'number': check_number(input), 'special': check_special(input), 'len' : check_len(input) } if check_upper(input) & check_lower(input) & check_number(input) & check_special(input) & check_len(input): return True else: print("Invalid password! Review below and change your password accordingly!") if check_dict['upper'] == False: print("Password needs at least one upper-case character.") if check_dict['lower'] == False: print("Password needs at least one lower-case character.") if check_dict['number'] == False: print("Password needs at least one number.") if check_dict['special'] == False: print("Password needs at least one special character.") if check_dict['len'] == False: print("Password needs to be at least 8 characters in length." ) print while True: password = input("Enter desired password: ") print if validate_password(password): print("Password meets all requirements and may be used.") print print("Exiting program...") print exit(0)

Decision Tree Regression Without Sklearn

Finally finished one split optimization.


#Imports from matplotlib import pyplot as plt from math import sqrt import numpy as np # Data X = np.array([1, 1, 2, 1, 2, 5, 6, 5, 7, 5]) y = np.array([2, 3, 2, 3, 3, 6, 7, 6 , 7, 7]) # Euclidean Distance def distance(x1, x2, y1, y2): return sqrt((x2 - x1)**2+(y2 - y1)**2) # Sum def sum(a): final = 0 for i in a: final += i return final # Calculate standard deviation def deviate(xleft, xright, yleft, yright, centroids): distance1 = [] distance2 = [] lxc, lyc = centroids[0] rxc, ryc = centroids[1] for i in range(0, len(xleft)-1): x = xleft[i] y = yleft[i] d = distance(lxc, x, lyc, y) distance1.append(d) for i in range(0, len(xright)-1): x = xright[i] y = yright[i] d = distance(rxc, x, ryc, y) distance2.append(d) return (np.std(distance1), np.std(distance2)) # Train function def train(X, y, split=2, step=1): split = split + 1 # Splits xleft, xright = X[:split], X[split:] yleft, yright = y[:split], y[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(X, y, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Call recursive function "regressor" return _train(np.delete(X, 0), np.delete(y, 0), split+1, opt=(0, split), optdev=std, step=step, initX=X, inity=y) # Recursive function def _train(X, y, split, opt=None, optdev=None, step=None, initX=None, inity=None): if len(X) < split+step: print("DONE WITH RECURSIVE PROCESS") print(f"RESULTS: Optimal Split:{opt}, Optimized Standard Deviation: left:{optdev[0]} right:{optdev[1]}") return (opt, optdev) # Splits xleft, xright = initX[:split], initX[split:] yleft, yright = inity[:split], inity[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(initX, inity, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Call recursive function "regressor" return _train(np.delete(X, 0), np.delete(y, 0), split+1, opt=opt, optdev=optdev, step=step, initX=initX, inity=inity) x = train(X, y, split=4)

Decision Tree Regression Without Sklearn

The main purpose of this program is to do decision tree regression without using any machine learning libraries (Keras, Sklearn, etc.) I'm currently in the process of creating the regressor. I'm using a recursive function to act as the regressor for my task.


#Imports from matplotlib import pyplot as plt from math import sqrt import numpy as np # Data X = np.array([1, 1, 2, 1, 2, 5, 6, 5, 7, 5]) y = np.array([2, 3, 2, 3, 3, 6, 7, 6 , 7, 7]) # Euclidean Distance def distance(x1, x2, y1, y2): return sqrt((x2 - x1)**2+(y2 - y1)**2) # Sum def sum(a): final = 0 for i in a: final += i return final # Calculate standard deviation for both sides def deviate(xleft, xright, yleft, yright, centroids): distance1 = [] distance2 = [] lxc, lyc = centroids[0] rxc, ryc = centroids[1] for i in range(0, len(xleft)-1): x = xleft[i] y = yleft[i] d = distance(lxc, x, lyc, y) distance1.append(d) for i in range(0, len(xright)-1): x = xright[i] y = yright[i] d = distance(rxc, x, ryc, y) distance2.append(d) return (np.std(distance1), np.std(distance2)) # Helper function that calculates initial split and calls recersive function def train(X, y, split=2): # Splits xleft, xright = X[:split], X[split:] yleft, yright = y[:split], y[split:] # Calculate centroids of each side x1, x2 = sum(xleft)/len(xleft), sum(xright)/len(xright) y1, y2 = sum(yleft)/len(yleft), sum(yright)/len(yright) # plot split plt.plot(np.append(split-1, split-1), np.array([0, 10])) centers = [(x1, y1), (x2, y2)] std = deviate(xleft, xright, yleft, yright, centers) # Plot data plt.scatter(X, y, marker="o") # plot centers plt.scatter(np.array(centers[0][0]), np.array(centers[0][1]), marker="v") plt.scatter(np.array(centers[1][0]), np.array(centers[1][1]), marker="v") plt.show() # Recursive Function def _train(X, y, split, opt=None, optdev=None): pass train(X, y, split=5)
Akhil Yeleswar Apr 11

nice work!

Sports Clothing Image Recognition

A project I worked on early last year involved taking an image of sports clothing and matching the image to the actual product on Amazon. It would be cool to see if someone could add extra features to this such that the program could retrieve the product from other clothing sites as well and filter for the cheapest ones. The video shows the current status of the project and the github link is here: https://github.com/akhily1/Sports-Apparel-Matching


1 ... 24 25