Show students the code sample and ask them to run it individually in the Repl interpreter. After 1-2 minutes ask the group: (1) what did the code do? (2) why?
def my_function():
print("THIS IS MY FUNCTION!")
# Name: my_greeting_function | |
# Purpose: Print a message to greet the user | |
# Inputs: User's name | |
# Outputs: None | |
def my_greeting_function(name): | |
full_greeting = 'Hello ' + name = '!' | |
print(full_greeting) | |
my_name = 'Sneha' | |
my_greeting_function(my_name) |
library(dplyr) | |
library(ggplot2) | |
library(gridExtra) | |
kBinwidth <- 1 | |
kXBreakBy <- 2 | |
kYBreakBy <- 1 | |
before_data <- c(17,6,4,1,3,18,19,15,13,13,10,8,13,11,2,7,5,17,15,15,2,9,20,18,19) | |
after_data <- c(17,13,13,5,4,6,9,9,6,14,18,5,9,3,2,12,9,2,4,14,3,13) |
# Install tidyr if necessary: | |
# install.packages('tidyr') | |
library(tidyr) | |
library(dplyr) | |
bands_wide <- data.frame( | |
city = c('Seattle', 'Portland', 'Denver', 'Minneapolis'), | |
greensky_bluegrass = c(40, 40, 20, 30), | |
trampled_by_turtles = c(30, 20, 40, 100), | |
billy_strings = c(15, 25, 25, 15), |
library(dplyr) | |
superheroes <- data.frame( | |
name = c( | |
'Magneto', 'Storm', 'Mystique', 'Batman', | |
'Joker', 'Catwoman', 'Hellboy' | |
), | |
alignment = c( | |
'bad', 'good', 'bad', 'good', 'bad', 'bad', 'good' | |
), |
# We are converting Andrey's height from feet to centimeters | |
feet <- 6 | |
inches <- 2 | |
# Convert 6 feet 2 inches to inches (what's wrong??) | |
inches_total <- 3 * feet + inches | |
# Convert inches_total to meters | |
meters_total <- inches_total / 39.37 |
console.log(JSON.stringify( | |
[...document | |
.querySelectorAll('.experience-section ul li')] | |
.map(jobElement => ({ | |
role: jobElement.querySelector('h3').innerText, | |
company: jobElement.querySelector('.pv-entity__secondary-title').innerText, | |
timeframe: jobElement.querySelector('.pv-entity__date-range span:not(.visually-hidden)').innerText, | |
description: jobElement.querySelector('.pv-entity__description').innerText.replace('See less', ''), | |
imageUrl: jobElement.querySelector('img').src | |
})) |
library(ggplot2) | |
library(dplyr) | |
library(stringr) | |
# Okay, the assignment description has a hint that we should use map_data('county') | |
# if we want to plot county-level data! | |
# Let's explore what that data looks like... | |
county_data <- map_data('county') | |
View(county_data) |
library(ggplot2) | |
# Set up a simple data frame for testing | |
my_data <- data.frame( | |
x = 1:20, | |
foo = 21:40, | |
bar = 41:60, | |
baz = 61:80 | |
) |
import { globalStore } from './main.js'; |