CS 105

Week 15

Grades

✔: Midterm 2: Free Response

✔: MP7

Late: Midterm 1 (Second Chance)
Needs gradebook display

Final Project
Expected: Today

Remaining Regrades
Expected: Today

Final Exam

Tuesday, May 12
8:00am - 11:00am


40-50 multiple choice questions
3-5 free response questions


Comprehensive
(JavaScript, Excel, basic d3.js)

Final Exam Review

Lecture Review
In-lecture on Wednesday


TA Review
1:00pm - 3:00pm on Thursday (Reading Day)
1000 Lincoln Hall


Regular Office Hours
Lab/office hours continue during exam week until exam day

Scratch



Functions and Variables

var square = function(num) {
  var result = num * num;
  return result;
}

Functions and Variables

var fun = function(a, b) {
  if (a > b) { return a * b; }
  else { return a / b; }
}
var r = fun(4, 2);
A) 0.5
B) 1
C) 2
D) 4
E) 8

Functions and Variables

var fun = function(a, b) {
  if (a > b) { return a * b; }
  else { return a / b; }
}
var r = fun(2, 4);
A) 0.5
B) 1
C) 2
D) 4
E) 8

Loops and Arrays

var sum = function(a) {
  var total = 0;
  for (var i = 0; i < a.length; i++) {
    total += a[i];
  }
  return total;
}
=SUM(A1:A7)

Loops and Arrays

var one_oh_five = function(a) {
  var t = 0;
  for (var i = 0; i < a.length; i++) {
    var x = a[i];
    if (x < 10) { t += x; }
    else if (x < 30) { t += x * 0.8; }
    else { t += x * 0.5; }
  }
  return t;
}
var one_oh_five = function(a) {
  var t = 0;
  for (var i = 0; i < a.length; i++) {
    var x = a[i];
    if (x < 10) { t += x; }
    else if (x < 30) { t += x * 0.8; }
    else { t += x * 0.5; }
  }
  return t;
}
var r = one_oh_five([100, 10, 100]);
var one_oh_five = function(a) {
  var t = 0;
  for (var i = 0; i < a.length; i++) {
    var x = a[i];
    if (x < 10) { t += x; }
    else if (x < 30) { t += x * 0.8; }
    else { t += x * 0.5; }
  }
  return t;
}
var r = one_oh_five([100, 10, 100]);
A) 8
B) 108
C) 110
D) 208
E) 210

SUMIFS

var sumifs = function(sum_array, sum_criteria, criteria) {
  var total = 0;
  for (var i = 0; i < sum_array.length; i++) {
    if ( criteria( sum_criteria[i] ) == true ) {
      total += sum_array[i];
    }
  }
  return total;
}
sumifs( [1, 2, 3, 4, 5],
        [10, 15, 20, 25, 30],
        function (d) { return (d > 20); } );

Data Types

var num = 43;     // Number
var s = "Hello";  // String
var b = true;     // Boolean
// Function:
var f = function(...) { ... }; 
// Array (of Strings):
var a1 = ["a", "b"];
// Array (of Numbers):
var a2 = [37, -375];  

Objects

var person = {
   fname: "Wade",
   lname: "Fagen",
   office: "2215 SC",
   areacode: 217
};
var x = person.fname;  // "Wade"

Excel: Arithmetic functions

SUM, SUMIFS
COUNT, COUNTIFS
AVERAGE, AVERAGEIFS
MAX, MIN

Excel: Lookup Function

VLOOKUP
INDEX, MATCH

Excel: Modelling / Forecasting

RAND

Excel: Pivot Tables

Machine Problems

  • MP0: Scratch project
  • MP1: Guess a random number
  • MP2: Instagram filters
  • MP3: Tic-tac-toe
  • MP4: reddit data set
  • MP5: Greatest movies of all time
  • MP6: Olympics
  • MP7: Olympics, Part 2
  • Lab 0: Scratch introduction
  • Lab 1: Underwater maze
  • Lab 2: Order girl scout cookies
  • Lab 3: Instagram filters
  • Lab 4: Blackjack game
  • Lab 5: Finding zero degree days
  • Lab 6: Finding palindromes in numbers
  • Lab 7: Data set on credit card transactions
  • Lab 8: Data set on labor and machine hours
  • Lab 9: Data set on locally sourced food
  • Lab 10: Pivot tables
  • Lab 11-13: Your final project!

Favorite MP?

  • (A): Scratch
  • (B): Guess a random number
  • (C): Instagram filters
  • (D): Tic-tac-toe
  • (E): Excel spreadsheets

Final Project

  • (A): I felt my team contributed equally

  • (B): I felt my team contributed somewhat un-equally, but NOT so much that others deserve a lower grade

  • (C): I felt my team contributed very un-equally, but SO MUCH SO that others deserve a lower grade

CS 205: Data Driven Discovery

  • Follow-on course to CS 105 -- designed for a second-semester programmer
  • Enrolment only open to non-CS majors -- you will not be competing with CS majors!
  • Focus on gathering and analysing data: images, text, maps, graphs, social networks, web APIs, and more
  • Python and JavaScript
  • Offered as CS 199.205 in Fall 2015