This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class Factory{ | |
private String SolidFood1; // Solid Food 1st Instance Variable | |
private String SolidFood2; // Solid Food 2nd Instance Variable | |
private String LiquidFood1; // Liquid Food 3rd Instance Variable | |
public Factory(){} // 0-arg constructor (Not used) | |
public Factory(String sf1, String sf2, String lf1){ // 3-arg constructor | |
SolidFood1 = sf1; | |
SolidFood2 = sf2; | |
LiquidFood1 = lf1; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Imports | |
import string | |
import random | |
import nltk | |
from nltk.tokenize import sent_tokenize, word_tokenize | |
from nltk.corpus import stopwords | |
from nltk.stem import PorterStemmer | |
from nltk.tokenize import PunktSentenceTokenizer | |
import sklearn | |
from sklearn.feature_extraction.text import TfidfVectorizer |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Base Class : Book | |
*Author : Rishi Sidhu | |
*Organization : AI Graduate | |
**/ | |
public class Book | |
{ | |
public String author; | |
public float costPrice; | |
public float salePrice; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Sub Class : EBook | |
*Author : Rishi Sidhu | |
*Organization : AI Graduate | |
**/ | |
public class EBook extends Book | |
{ | |
public String downloadSite; | |
public int sizeMB; | |
public EBook(String au, float cp, float sp, String tl, int pg, String ds, int sz){ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
/** | |
*Test Class : TestBook | |
*Author : Rishi Sidhu | |
*Organization : AI Graduate | |
**/ | |
public class TestBook | |
{ | |
public static void main(String[] args){ // Main Method - Only this method gets executed | |
//Create a Book object | |
Book book1 = new Book("Gary Rich", 8.99f, 19.99f, "How to get rich", 100); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import java.util.Random; | |
public class Histogram { | |
static int NUM_STUDENTS = 20000; | |
static int HIGHEST_GRADE = 10; | |
//Function to compute histogram faster O(N) | |
public void getHistFast(int iArr[], int oArr[]) | |
{ | |
for(int i=0;i<iArr.length;i++) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from sklearn.datasets import load_iris | |
from sklearn import tree | |
import numpy as np | |
from graphviz import Source | |
iris = load_iris() | |
print("Feature Names - ", iris.feature_names,"\n") | |
print(iris.target) | |
#Print the row 0,50 and 100 i.e. 1 example for each type | |
print("\nSetosa flower 1 - ",iris.data[0]) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
a = 10 # Integer | |
b = -9 # Integer can be negative | |
c = 0b011 # Integer can be Binary | |
d = 0o123 # Integer can be Octal | |
e = 0x9AF # Integer can be Hexadecimal | |
print("Positive Integer = ",a, " | ", type(a)) | |
print("Negative Integer = ",b, " | ", type(b)) | |
print("Binary Integer = ",c, " | ", type(c)) | |
print("Octal Integer = ",d, " | ", type(d)) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
in1 = 1+2j # Complex Number | |
fl1 = 0.78 # Float | |
fl2 = 2.6e-2 # Float with scientific notation. e means 10^ | |
fl3 = 1.8*10**308 +1 # One greater than the maximum float | |
bl1 = True # Boolean True | |
bl2 = False # Boolean False | |
st1 = "Hello World!" # String | |
bt1 = b"hola" # Byte |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#Lists | |
l2 = [4,1,3,9,7] | |
l3 = ['a','ab', 'abc','ab', 'ab'] | |
#List Methods | |
l2.sort() # Sort | |
l2.append(12) # Add an element at the end | |
sum(l2) # Sum all the elements | |
max(l2) # Find the maximum element | |
min(l2) # Find the minimum element |
OlderNewer