//Sample Solution
const gameState = {}
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
gameState.codey = this.add.sprite(150, 200, 'codey')
// Set cursor keys here!
gameState.cursors = this.input.keyboard.createCursorKeys();
}
function update() {
// Update based on keypress here!
if(gameState.cursors.right.isDown){
gameState.codey.x += 5
}
if(gameState.cursors.left.isDown){
gameState.codey.x -= 5
}
if(gameState.cursors.up.isDown){
gameState.codey.y -= 5
}
if(gameState.cursors.down.isDown){
gameState.codey.y += 5
}
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 500,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
update
}
}
const game = new Phaser.Game(config)
Quotes help make search much faster. Example: "Practice Makes Perfect"
Showing posts with label Codecademy. Show all posts
Showing posts with label Codecademy. Show all posts
Monday, September 9, 2019
Codecademy Learn Phaser: Basics Storing State 8/12
//Sample Solution
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
const gameState = {};
function create() {
gameState.circle = this.add.circle(40, 100, 20, 0xff9999)
}
function update() {
gameState.circle.y += 1
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#99ff99",
scene: {
create,
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Move Your Bodies 7/12
//Sample Solution
let codey;
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
codey = this.add.sprite(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
let codey;
function preload() {
this.load.image('codey', 'https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png');
}
function create() {
codey = this.add.sprite(30, 200, 'codey')
}
// Create your update() function here
function update() {
codey.x += 1;
}
const config = {
type: Phaser.AUTO,
width: 400,
height: 400,
backgroundColor: "#5f2a55",
scene: {
preload,
create,
// Include update here!
update
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Start Making A Scene 6/12
//Sample Solution
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
// Create a create() function here:
function create() {
this.add.text(100,170,"Spaze Invaydurs");
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#a0a0dd",
// Add in the scene information in the config here:
scene: {
create
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Create A Config 5/12
//Sample Solution
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
const config = {
width: 450,
height: 600,
backgroundColor: "#0000ff",
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Background Image 4/12
//Sample Solution
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the background image here!
this.load.image('sky','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/sky.jpg');
}
function create() {
// Put the background image in the scene here!
this.add.image(200,200,'sky');
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Sprite 3/12
//Sample Solution
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
function preload() {
// Load in the sprite here!
this.load.image('codey','https://s3.amazonaws.com/codecademy-content/courses/learn-phaser/codey.png')
}
function create() {
// Create a sprite game object here!
this.add.sprite(40,50,'codey')
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create,
preload
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Draw A Circle 2/12
//Sample Solution
function create() {
let circle1 = this.add.circle(50, 100, 90, 0xFFF070);
let circle2 = this.add.circle(95, 300, 80, 0xFF0000);
let circle3 = this.add.circle(200, 200, 100, 0x9F00D0);
let circle4 = this.add.circle(300, 400, 10, 0x00E030);
// Add in a circle here!
let circle5 = this.add.circle(450, 600, 240, 0xFFFFFF);
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
scene: {
create
}
}
const game = new Phaser.Game(config)
function create() {
let circle1 = this.add.circle(50, 100, 90, 0xFFF070);
let circle2 = this.add.circle(95, 300, 80, 0xFF0000);
let circle3 = this.add.circle(200, 200, 100, 0x9F00D0);
let circle4 = this.add.circle(300, 400, 10, 0x00E030);
// Add in a circle here!
let circle5 = this.add.circle(450, 600, 240, 0xFFFFFF);
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
scene: {
create
}
}
const game = new Phaser.Game(config)
Codecademy Learn Phaser: Basics Hello World 1/12
//Sample Solution
function create() {
// Change "Codey's Adventures\n in Code World" to the name of your game
this.add.text(50, 100, "Nathan's Nation", { font: "40px Times New Roman", fill: "#ffa0d0"});
// Change "by Codecademy" to your name!
this.add.text(130, 300, "by nathan", { font: "20px Times New Roman", fill: "#ffa0d0"});
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create
}
};
const game = new Phaser.Game(config);
function create() {
// Change "Codey's Adventures\n in Code World" to the name of your game
this.add.text(50, 100, "Nathan's Nation", { font: "40px Times New Roman", fill: "#ffa0d0"});
// Change "by Codecademy" to your name!
this.add.text(130, 300, "by nathan", { font: "20px Times New Roman", fill: "#ffa0d0"});
}
const config = {
type: Phaser.AUTO,
width: 450,
height: 600,
backgroundColor: "#5f2a55",
scene: {
create
}
};
const game = new Phaser.Game(config);
Codecademy Hypothesis Testing With R ANOVA 13/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("dist_one.Rda")
load("dist_two.Rda")
load("dist_three.Rda")
load("dist_four.Rda")
```
```{r}
# plot histograms and define not_normal here:
hist(dist_one)
hist(dist_two)
hist(dist_three)
hist(dist_four)
not_normal <- 4
```
```{r}
# define ratio here:
ratio <- sd(dist_two)/sd(dist_three)
ratio
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("dist_one.Rda")
load("dist_two.Rda")
load("dist_three.Rda")
load("dist_four.Rda")
```
```{r}
# plot histograms and define not_normal here:
hist(dist_one)
hist(dist_two)
hist(dist_three)
hist(dist_four)
not_normal <- 4
```
```{r}
# define ratio here:
ratio <- sd(dist_two)/sd(dist_three)
ratio
```
Codecademy Hypothesis Testing With R ANOVA 12/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load libraries
library(tidyr)
```
```{r message = FALSE}
# load data
load("stores.Rda")
load("stores_new.Rda")
```
```{r}
# inspect stores here:
stores
```
```{r}
# perform anova on stores here:
results = aov(sales ~ store, data = stores)
summary(results)
```
```{r}
# perform anova on stores_new here:
results_new = aov(sales ~ store, data = stores_new)
summary(results_new)
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load libraries
library(tidyr)
```
```{r message = FALSE}
# load data
load("stores.Rda")
load("stores_new.Rda")
```
```{r}
# inspect stores here:
stores
```
```{r}
# perform anova on stores here:
results = aov(sales ~ store, data = stores)
summary(results)
```
```{r}
# perform anova on stores_new here:
results_new = aov(sales ~ store, data = stores_new)
summary(results_new)
```
Codecademy Hypothesis Testing With R Dangers of Multiple T-Tests 11/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("store_a.Rda")
load("store_b.Rda")
load("store_c.Rda")
```
```{r}
# calculate means here:
store_a_mean <- mean(store_a)
store_a_mean
store_b_mean <- mean(store_b)
store_b_mean
store_c_mean <- mean(store_c)
store_c_mean
```
```{r}
# calculate standard deviations here:
store_a_sd <- sd(store_a)
store_a_sd
store_b_sd <- sd(store_b)
store_b_sd
store_c_sd <- sd(store_c)
store_c_sd
```
```{r}
# perform two sample t-test here:
a_b_results <- t.test(store_a,store_b)
a_b_results
a_c_results <- t.test(store_a,store_c)
a_c_results
b_c_results <- t.test(store_b,store_c)
b_c_results
```
```{r}
# calculate error_prob here:
error_prob <- (1-(0.95**3))
error_prob
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("store_a.Rda")
load("store_b.Rda")
load("store_c.Rda")
```
```{r}
# calculate means here:
store_a_mean <- mean(store_a)
store_a_mean
store_b_mean <- mean(store_b)
store_b_mean
store_c_mean <- mean(store_c)
store_c_mean
```
```{r}
# calculate standard deviations here:
store_a_sd <- sd(store_a)
store_a_sd
store_b_sd <- sd(store_b)
store_b_sd
store_c_sd <- sd(store_c)
store_c_sd
```
```{r}
# perform two sample t-test here:
a_b_results <- t.test(store_a,store_b)
a_b_results
a_c_results <- t.test(store_a,store_c)
a_c_results
b_c_results <- t.test(store_b,store_c)
b_c_results
```
```{r}
# calculate error_prob here:
error_prob <- (1-(0.95**3))
error_prob
```
Codecademy Hypothesis Testing With R Two-Sample T-Test 10/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("week_1.Rda")
week_1
load("week_2.Rda")
week_2
```
```{r}
# calculate week_1_mean and week_2_mean here:
week_1_mean <- mean(week_1)
week_1_mean
week_2_mean <- mean(week_2)
week_2_mean
```
```{r}
# calculate week_1_sd and week_2_sd here:
week_1_sd <- sd(week_1)
week_1_sd
week_2_sd <- sd(week_2)
week_2_sd
```
```{r}
# run two sample t-test here:
results <- t.test(week_1,week_2)
results
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load data
load("week_1.Rda")
week_1
load("week_2.Rda")
week_2
```
```{r}
# calculate week_1_mean and week_2_mean here:
week_1_mean <- mean(week_1)
week_1_mean
week_2_mean <- mean(week_2)
week_2_mean
```
```{r}
# calculate week_1_sd and week_2_sd here:
week_1_sd <- sd(week_1)
week_1_sd
week_2_sd <- sd(week_2)
week_2_sd
```
```{r}
# run two sample t-test here:
results <- t.test(week_1,week_2)
results
```
Codecademy Hypothesis Testing With R One-Sample T-Test 9/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load and view data
load("ages.Rda")
ages
```
```{r}
# calculate ages_mean here:
ages_mean <- mean(ages)
ages_mean
```
```{r}
# perform t-test here:
results <- t.test(ages,mu=30)
results
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r message = FALSE}
# load and view data
load("ages.Rda")
ages
```
```{r}
# calculate ages_mean here:
ages_mean <- mean(ages)
ages_mean
```
```{r}
# perform t-test here:
results <- t.test(ages,mu=30)
results
```
Codecademy Hypothesis Testing With R Significance Level 8/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# update reject_hypothesis here:
# all p-values below the threshold will result in # # rejecting the null hypothesis
# p-value threshold industry = 0.05
# hypothesis test actual p-value = 0.1 > 0.05
# since p-value is larger than the threshold, we # accept the null hypothesis
reject_hypothesis <- FALSE
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# update reject_hypothesis here:
# all p-values below the threshold will result in # # rejecting the null hypothesis
# p-value threshold industry = 0.05
# hypothesis test actual p-value = 0.1 > 0.05
# since p-value is larger than the threshold, we # accept the null hypothesis
reject_hypothesis <- FALSE
```
Codecademy Hypothesis Testing With R P-Values 7/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# possible interpretations
st_1 <- "There is a 20% chance that the difference in average weight of green and red apples is due to random sampling."
st_2 <- "There is a 20% chance that green and red apples have the same average weight."
st_3 <- "There is a 20% chance red apples weigh more than green apples."
st_4 <- "There is a 20% chance green apples weigh more than green apples."
# update the value of interpretation here:
interpretation <- "st_1"
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# possible interpretations
st_1 <- "There is a 20% chance that the difference in average weight of green and red apples is due to random sampling."
st_2 <- "There is a 20% chance that green and red apples have the same average weight."
st_3 <- "There is a 20% chance red apples weigh more than green apples."
st_4 <- "There is a 20% chance green apples weigh more than green apples."
# update the value of interpretation here:
interpretation <- "st_1"
```
Codecademy Hypothesis Testing With R Type I and Type II Errors 6/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# the true positives and negatives:
actual_positive <- c(2, 5, 6, 7, 8, 10, 18, 21, 24, 25, 29, 30, 32, 33, 38, 39, 42, 44, 45, 47)
actual_negative <- c(1, 3, 4, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 26, 27, 28, 31, 34, 35, 36, 37, 40, 41, 43, 46, 48, 49)
# the positives and negatives we determine by running the experiment:
experimental_positive <- c(2, 4, 5, 7, 8, 9, 10, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 27, 28, 32, 35, 36, 38, 39, 40, 45, 46, 49)
experimental_negative <- c(1, 3, 6, 12, 14, 23, 25, 29, 30, 31, 33, 34, 37, 41, 42, 43, 44, 47, 48)
```
```{r}
# define type_i_errors and type_ii_errors here:
type_i_errors = intersect(experimental_positive,actual_negative)
type_i_errors
type_ii_errors =
intersect(experimental_negative,actual_positive)
type_ii_errors
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# the true positives and negatives:
actual_positive <- c(2, 5, 6, 7, 8, 10, 18, 21, 24, 25, 29, 30, 32, 33, 38, 39, 42, 44, 45, 47)
actual_negative <- c(1, 3, 4, 9, 11, 12, 13, 14, 15, 16, 17, 19, 20, 22, 23, 26, 27, 28, 31, 34, 35, 36, 37, 40, 41, 43, 46, 48, 49)
# the positives and negatives we determine by running the experiment:
experimental_positive <- c(2, 4, 5, 7, 8, 9, 10, 11, 13, 15, 16, 17, 18, 19, 20, 21, 22, 24, 26, 27, 28, 32, 35, 36, 38, 39, 40, 45, 46, 49)
experimental_negative <- c(1, 3, 6, 12, 14, 23, 25, 29, 30, 31, 33, 34, 37, 41, 42, 43, 44, 47, 48)
```
```{r}
# define type_i_errors and type_ii_errors here:
type_i_errors = intersect(experimental_positive,actual_negative)
type_i_errors
type_ii_errors =
intersect(experimental_negative,actual_positive)
type_ii_errors
```
Codecademy Hypothesis Testing With R Designing an Experiment 5/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# load data
load("retriever_lengths.Rda")
load("doodle_lengths.Rda")
```
```{r}
# calculate mean_retriever_l and mean_doodle_l here:
mean_retriever_l = mean(retriever_lengths)
mean_doodle_l = mean(doodle_lengths)
mean_retriever_l
mean_doodle_l
```
```{r}
# calculate mean_difference here:
mean_difference = mean_retriever_l - mean_doodle_l
mean_difference
```
```{r}
# statements:
st_1 <- "The average length of Golden Retrievers is 2.5 inches longer than the average length of Goldendoodles."
st_2 <- "The average length of Golden Retrievers is the same as the average length of Goldendoodles."
# update null_hypo here:
null_hypo <- "st_2"
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# load data
load("retriever_lengths.Rda")
load("doodle_lengths.Rda")
```
```{r}
# calculate mean_retriever_l and mean_doodle_l here:
mean_retriever_l = mean(retriever_lengths)
mean_doodle_l = mean(doodle_lengths)
mean_retriever_l
mean_doodle_l
```
```{r}
# calculate mean_difference here:
mean_difference = mean_retriever_l - mean_doodle_l
mean_difference
```
```{r}
# statements:
st_1 <- "The average length of Golden Retrievers is 2.5 inches longer than the average length of Goldendoodles."
st_2 <- "The average length of Golden Retrievers is the same as the average length of Goldendoodles."
# update null_hypo here:
null_hypo <- "st_2"
```
Saturday, September 7, 2019
Codecademy Hypothesis Testing With R Hypothesis Formulation 4/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# experiment 1
hypo_a <- "DeePressurize lowers blood pressure in patients."
hypo_b <- "DeePressurize has no effect on blood pressure in patients."
null_hypo_1 <- "hypo_b"
```
```{r}
# experiment 2
hypo_c <- "The new profile layout has no effect on number of matches with other users."
hypo_d <- "The new profile layout results in more matches with other users than the original layout."
null_hypo_2 <- "hypo_c"
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# experiment 1
hypo_a <- "DeePressurize lowers blood pressure in patients."
hypo_b <- "DeePressurize has no effect on blood pressure in patients."
null_hypo_1 <- "hypo_b"
```
```{r}
# experiment 2
hypo_c <- "The new profile layout has no effect on number of matches with other users."
hypo_d <- "The new profile layout results in more matches with other users than the original layout."
null_hypo_2 <- "hypo_c"
```
Codecademy Hypothesis Testing With R Sample Mean and Population Mean - I 2/14
#Sample Solution
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# generate random population
population <- rnorm(300, mean=65, sd=3.5)
# calculate population mean here:
population_mean <- mean(population)
population_mean
```
```{r}
# generate sample 1
sample_1 <- sample(population, size=30)
sample_1
# calculate sample 1 mean
sample_1_mean <- mean(sample_1)
sample_1_mean
```
```{r}
# generate samples 2,3,4 and 5
sample_2 <- sample(population, size=30)
sample_3 <- sample(population, size=30)
sample_4 <- sample(population, size=30)
sample_5 <- sample(population, size=30)
```
```{r}
# calculate sample means here:
sample_2_mean <- mean(sample_2)
sample_2_mean
sample_3_mean <- mean(sample_3)
sample_3_mean
sample_4_mean <- mean(sample_4)
sample_4_mean
sample_5_mean <- mean(sample_5)
sample_5_mean
```
---
title: "Hypothesis Testing in R"
output: html_notebook
---
```{r}
# generate random population
population <- rnorm(300, mean=65, sd=3.5)
# calculate population mean here:
population_mean <- mean(population)
population_mean
```
```{r}
# generate sample 1
sample_1 <- sample(population, size=30)
sample_1
# calculate sample 1 mean
sample_1_mean <- mean(sample_1)
sample_1_mean
```
```{r}
# generate samples 2,3,4 and 5
sample_2 <- sample(population, size=30)
sample_3 <- sample(population, size=30)
sample_4 <- sample(population, size=30)
sample_5 <- sample(population, size=30)
```
```{r}
# calculate sample means here:
sample_2_mean <- mean(sample_2)
sample_2_mean
sample_3_mean <- mean(sample_3)
sample_3_mean
sample_4_mean <- mean(sample_4)
sample_4_mean
sample_5_mean <- mean(sample_5)
sample_5_mean
```
Subscribe to:
Posts (Atom)
This is an example of scrolling text using Javascript.
Popular Posts
-
//Sample Solution const gameState = {} function preload() { this.load.image('codey', 'https://s3.amazonaws.com/codecademy-...
-
//sample solution function guessNumber(number, clue) { // Prompt the user for a number using the string value of clue guess = promp...
-
//sample solution //Here is the original card object var card1 = {"suit":"clubs", "rank": 8}; //Create a...
-
#sample solution def colorful_conditions(): color = "blue" if color == "red": return "firs...
-
function checkAnswerWrongPlace(ans, realanswer){ // This method compares two input strings representing a player's guess ("an...
-
Instruction: Find the id of the flights whose distance is below average for their carrier. Sample Solution: SELECT id FROM flights AS f...
-
# note: The instructions state to use "text.txt" but an error comes up stating that the file does not exist # as a work around, ...
-
# Sample Solution # Import packages import numpy as np import pandas as pd # Read in transactions data transactions = pd.read_csv(...
-
# Sample Solution from song_data import songs import numpy as np q1 = np.quantile(songs, 0.25) #Create the variables q3 and interquarti...
-
/*sample solution for style.css*/ body > p { background: green; } p { background: yellow; }