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
low = 0 | |
high = 100 | |
guess = (low + high) // 2 | |
ans = "" | |
userInput = input('Please think of a number between 0 and 100!') | |
while True: | |
print('Is Your secret number ' + str(guess) + '?') | |
ans = input("Enter 'h' to indicate the guess is too high. Enter 'l' to indicate the guess is too low. Enter 'c' to indicate I guessed correctly. ") | |
if ans == 'c': |
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
library(pitchRx) | |
library(tidyverse) | |
data <- scrape(start = "2011-04-04", end = "2011-06-01") | |
pitches <- data[["pitch"]] | |
ab <- data[["atbat"]] | |
newDat <- merge(pitches, ab, by = c("num", "gameday_link")) | |
newDat <- newDat[1:95] |
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
# read in data | |
NEI <- readRDS("summarySCC_PM25.rds") | |
SCC <- readRDS("Source_Classification_Code.rds") | |
# load packages | |
library(tidyverse) | |
# convert to proper class | |
SCC$SCC <- as.character(SCC$SCC) | |
SCC$EI.Sector <- as.character(SCC$EI.Sector) |
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
# reading in data | |
NEI <- readRDS("summarySCC_PM25.rds") | |
SCC <- readRDS("Source_Classification_Code.rds") | |
# load packages | |
library(tidyverse) | |
# convert to proper class | |
SCC$SCC <- as.character(SCC$SCC) | |
SCC$EI.Sector <- as.character(SCC$EI.Sector) |
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
# lists to test | |
foo = ['apples', 'bananas', 'tofu', 'cats'] | |
a = ['bat', 'rat', 'elephant', 'snake', 'hippo'] | |
b = ['Ben', 'Ryan', 'Arthur', 'Dillon', 'Andre', 'Agnes', 'Aaron'] | |
d = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j'] | |
# comma code function | |
def commaCode(myList): | |
s = '' # creates an empty string vector | |
last = myList[len(myList) - 1] # gets the last value from the list |
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
/* How many albums does the artist Led Zepplin have? */ | |
SELECT COUNT(Albumid) AS totalAlbums | |
FROM albums | |
WHERE Artistid = (SELECT Artistid FROM artists WHERE name = 'Led Zeppelin') | |
/* Create a list of album titles and the unit prices for the artist Audioslave */ | |
SELECT n.Name, u.UnitPrice | |
FROM ((albums t INNER JOIN artists n | |
ON t.Artistid = n.Artistid) | |
INNER JOIN tracks u ON t.Albumid = u.Albumid) |
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
/* Self join * / | |
/* How many stops are in the database */ | |
SELECT COUNT(*) | |
FROM stops | |
/* Find the id value for the stop Craiglockhart */ | |
SELECT id | |
FROM stops | |
WHERE name = 'Craiglockhart' |
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
/* Using NULL */ | |
/* List the teachers who have NULL for their department */ | |
SELECT name | |
FROM teacher | |
WHERE dept IS NULL | |
/* Use a different JOIN so that all teachers are listed */ | |
SELECT teacher.name, dept.name | |
FROM teacher LEFT JOIN dept ON teacher.dept = dept.id |
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
/* More JOIN */ | |
/* Give year of Citizen Kane */ | |
SELECT yr | |
FROM movie | |
WHERE title = 'Citizen Kane' | |
/* List all of the Star Trek movies, include the id, title and yr (all of these movies include the words Stark Trek in the title). Order results by year */ | |
SELECT id, title, yr | |
FROM movie | |
WHERE title LIKE 'Star Trek%' |
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
/* Show matchid and player name for all goals scored by Germany */ | |
SELECT matchid, player | |
FROM goal | |
WHERE teamid = 'GER' | |
/* Show id, stadium, team1, team2 for just game 1012 */ | |
SELECT id, stadium, team1, team2 | |
FROM game | |
WHERE id = 1012 |
NewerOlder