This file contains hidden or 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
//Q1 | |
let num = 10; | |
//Q2 | |
let add8 = num + 8; | |
//Q3 | |
let subtract6 = num - 6; | |
//Q4 |
This file contains hidden or 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
//challenge 2 | |
function findStudentName(studentList, sn) { | |
studentList = studentList.sort(function (a, b) { | |
return a.sn - b.sn | |
}); | |
return studentList[sn - 1].name; | |
} | |
function findStudent(studentList, sn) { | |
studentList = studentList.sort(function (a, b) { |
This file contains hidden or 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
/* Arrays II slide 10*/ | |
//https://www.w3schools.com/jsref/jsref_findindex.asp | |
let groceryList = [{ // use curly brackets and key/value pairs (attributes of "object") syntax to make array of objects | |
item: "milk", purchased: false | |
}, { | |
item: "salad", purchased: false | |
}, { | |
item: "cereal", purchased: false | |
}, { | |
item: "juice", purchased: false |
This file contains hidden or 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.*; | |
import java.io.*; | |
public class Miniane { | |
public static void printTree(int height) throws FileNotFoundException { //This is the correct exception to throw | |
File file = new File("test.txt"); | |
PrintWriter out = new PrintWriter(file); | |
for(int i = 1; i <= height; i++){ //Use i=1 so that * will be repeated i times for each line | |
out.println("*".repeat(i)); //string.repeat will return the string repeated [int] amount of times | |
} |
This file contains hidden or 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.*; | |
public class Miniane { | |
public static void main(String[] args) { | |
Scanner scan = new Scanner(System.in); | |
int[] ints = new int[5]; | |
int lengthi = ints.length; | |
for (int i = 0; i < ints.length; i++){ |
This file contains hidden or 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
x1 = [0 1 4;2 3 5;2 6 3]; | |
y1 = [0 4 5;7 8 6;3 1 5]; | |
z1 = [0 2 1;5 6 6;2 8 8]; | |
c = [6 3 0;5 6 4; 0 2 3]; | |
patch(x1,y1,z1,c) | |
view(3) | |
v1 = [0 0 0;2 7 0;2 3 0;2 7 5;2 3 2] | |
f1 = [1 2 3;1 2 4;1 3 5] | |
patch('Faces', f1,'Vertices',v1,'FaceColor','magenta') |
This file contains hidden or 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
class Node: | |
def __init__(self, label: str, edges: list): | |
self.label = label | |
self.edges = edges | |
def __str__(self): | |
size = len(self.edges) | |
return 'Node {self.label} has {size} edges, {self.edges}'.format(self=self, size=size) | |
def add_outgoing_edge(self, newEdge): |
This file contains hidden or 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
function shapes(n) | |
function test(n) | |
axis('equal'); | |
view ([-1 -1 1]); | |
xlabel('x'); | |
ylabel('y'); | |
zlabel('z'); | |
%draw lab section 8 Last name A-J |
This file contains hidden or 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 csv | |
def getData(dataFile): | |
headings = [] # list for headings of data | |
rows = [] # list for rows of data | |
with open(dataFile, 'r') as file: | |
reader = csv.reader(file) # create csv reader object | |
headings = next(reader) # store headings using 1st row of file |
This file contains hidden or 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 A3Q3 { | |
static double dydx(double x){ | |
double k = 0.5, a = 2, b = 1; | |
return k * (a - x) * Math.pow((b - x), 0.5); | |
} | |
static double euler(double n){ | |
double solution = 0, x0 = 0, t = 0, x, slope, h = 1/n; |