Bootstrap starter template

If you can cook, you can program.

A computer program is a recipe for a computer. The computer reads the recipe and you get a game like Angry Birds, a word processor like Microsoft Office, or a website like Youtube. Recipes have various ingredients. They also have directions or instructions for using those ingredients. The ingredients of a computer program are called variables. The instructions of a computer program are called statements. A group of statements is called a function.

Data

The ingredients of a computer program are called data. There are different types of data. Data is stored in variables.

Python

        name = 'Southern Style Grits'
        water = 4
        grits = water/4
        cheese = 2.5
        seasonings = ['pepper','salt','basil']
        amounts = {
          seasonings[0]:'1tbsp',
          seasonings[1]:'1tsp',
          seasonings[2]:'1tsp'
        }
        

Javascript

        var name = "Southern Style Grits"
        var water = 4
        var grits = water/4
        var cheese = 2.5
        var seasonings = ['pepper','salt','basil']
        var amounts = {
          seasonings[0]:'1tbsp',
          seasonings[1]:'1tsp',
          seasonings[2]:'1tsp'
        }
        
Common types of data are:
        character - a single character as in "a"
        string - a string of characters as in "Hello World"
        integer - a number
        float - a number with a decimal
        array - a list of data
        dictionary - a list with an entry-definition-like structure called key:value pairs.
        boolean - true or false
        

Statements

Statements are the instructions of a computer program.

        print(grits)
        input("How old are you?")
        

Functions

A function is a group of statements.

Python

        def total(a,b):
          print(a+b)
          print(“That is the total”)
          
        total(water,grits)
        

Javascript

        function total(a,b){
          console.log(a+b);
          console.log(“That is the total”);
        }
        total(water,grits);
        

Classes

A Class is a ___ of statements

Python

        class Mathematician(self,name,age):
            __init__(self):
                self.name = name;
                self.age = age
            def sum(a,b):
                return a+b
                
        joe = Mathematician('Joe',24)
        print(joe.sum(4,5))
        

Javascript

        class Mathematician{
          constructor(name,age){
            this.name = name;
            this.age = age;
          }
          sum(a,b){
            return a+b;
          }
        }
        joe = new Mathematician('Joe',24);
        console.log(joe.sum(4,5));
        

SQL

SQL is a langauge for manipulating databases.

        /*select * from jobs where Pay != "NULL" and Pay != ""*/
        /*select * from jobs where Applied = "YES"*/
        /*select * from jobs where Title != "" and Title != "NULL" and Url != "NULL" and Url != ""*/
        /*select *from jobs where Date = "2/2/18"*/
        /*select * from jobs where Platform LIKE "Car%"*/
        /*select * from jobs where Url LIKE "%car%"*/
        /*select * from jobs where Title LIKE "%__thon%"*/
        SELECT COUNT(Applied) FROM Jobs WHERE Applied="YES"
        SELECT COUNT(DISTINCT location) FROM Jobs
        SELECT * FROM Jobs LIMIT 5
        SELECT first_name,last_name FROM customer
        ORDER BY first_name ASC;
        SELECT Title,Company FROM Jobs WHERE Company !="NULL" AND Company != "" AND Title!=""
        ORDER BY Title ASC, Company DESC
        /*two people with same first name, sorted by last name first. order by multiple columns*/
        select Title,Company from Jobs where Company not in("NULL","") AND Title !=""
        order by Title asc, Company desc
        /*IN IS like a series of OR statements*/


        select customer_id,amount from payment where amount between 8 and 9;
        select customer_id,amount from payment where amount not between 8 and 9;
        select amount,payment_date from payment where payment_date between '2007-02-07' and '2007-02-15';
        select customer_id,rental_id,return_date from rental where customer_id IN(1,2) order by return_date desc;

        select customer_id,rental_id,return_date
        from rental
        where customer_id IN(7,13,10)
        order by return_date desc

        select first_name from customer
        where first_name like('Jen%')

        select first_name,last_name from customer
        where first_name like('%y');

        select first_name,last_name from customer
        where first_name like('%er%');

        select first_name,last_name from customer
        where first_name like('_her%');

        select first_name,last_name from customer
        where first_name not like 'Jen%';

        select first_name,last_name from customer
        where first_name ilike 'BAR%'; /*case insenstitive*/

        /*GENERAL CHALLENGE*/
        select COUNT(amount) from payment where amount > 5;
        select count(*) from actor where first_name like 'P%';
        select distinct(district) from address;
        select count(*) from film where rating='R' and replacement_cost between 5 and 15;
        select count(*) from film where title like('%Truman%');