Skip to content

Instantly share code, notes, and snippets.

@aparrish
Created February 27, 2018 20:12
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save aparrish/0057f8cbf12ecf79766d2fc6bcd252e7 to your computer and use it in GitHub Desktop.
Save aparrish/0057f8cbf12ecf79766d2fc6bcd252e7 to your computer and use it in GitHub Desktop.
rwet notes 2018-02-23
Display the source blob
Display the rendered blob
Raw
{
"cells": [
{
"cell_type": "markdown",
"metadata": {},
"source": [
"# notes for 2018-02-23\n",
"\n",
" // javascript\n",
" for (let i = 0; i < 100; i++) { console.log(i); ellipse(random(width),\n",
" random(height), 100,\n",
" 100);\n",
" }\n",
" \n",
" for item in list:\n",
" print()\n",
" print()"
]
},
{
"cell_type": "code",
"execution_count": 1,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"cheeses = [\"cheddar\", \"camembert\", \"brie\", \"parmesan\", \"gorgonzola\", \"goat\"]"
]
},
{
"cell_type": "code",
"execution_count": 7,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"cheddar\n",
"camembert\n",
"brie\n",
"parmesan\n",
"gorgonzola\n",
"goat\n"
]
}
],
"source": [
"print(\"\\n\".join(cheeses))"
]
},
{
"cell_type": "code",
"execution_count": 8,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import random"
]
},
{
"cell_type": "code",
"execution_count": 10,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"CAMEMBERT\n",
"CHEDDAR\n",
"GORGONZOLA\n",
"PARMESAN\n"
]
}
],
"source": [
"for item in random.sample(cheeses, 4):\n",
" yell_cheese = item.upper()\n",
" print(yell_cheese)"
]
},
{
"cell_type": "code",
"execution_count": 13,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"0\n",
"💩\n",
"1\n",
"💩\n",
"2\n",
"💩\n",
"3\n",
"💩\n",
"4\n",
"💩\n",
"5\n",
"💩\n",
"6\n",
"💩\n",
"7\n",
"💩\n",
"8\n",
"💩\n",
"9\n",
"💩\n",
"10\n",
"💩\n",
"11\n",
"💩\n",
"12\n",
"💩\n",
"13\n",
"💩\n",
"14\n",
"💩\n",
"15\n",
"💩\n",
"16\n",
"💩\n",
"17\n",
"💩\n",
"18\n",
"💩\n",
"19\n",
"💩\n"
]
}
],
"source": [
"for i in range(20):\n",
" print(i)\n",
" print(\"💩\")"
]
},
{
"cell_type": "code",
"execution_count": 16,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"50\n",
"55\n",
"60\n",
"65\n",
"70\n",
"75\n",
"80\n",
"85\n",
"90\n",
"95\n"
]
}
],
"source": [
"for i in range(50, 100, 5):\n",
" print(i)"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
" // javascript\n",
" for (let x = 0; x < width; x += 50) {\n",
" }\n",
" \n",
" for i in range(0, width, 50):\n",
" # something here"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"## write a computer-generated acrostic\n",
"\n",
" seed phrase (phrase to spell out)\n",
" source text (draw the lines of poetry)\n",
" \n",
" ROBERT FROST"
]
},
{
"cell_type": "code",
"execution_count": 17,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"words = open(\"frost.txt\").read().split()"
]
},
{
"cell_type": "code",
"execution_count": 25,
"metadata": {},
"outputs": [],
"source": [
"r_words = [item for item in words if item.startswith(\"r\")]\n",
"o_words = [item for item in words if item.startswith(\"o\")]\n",
"b_words = [item for item in words if item.startswith(\"b\")]\n",
"e_words = [item for item in words if item.startswith(\"e\")]\n",
"t_words = [item for item in words if item.startswith(\"t\")]"
]
},
{
"cell_type": "code",
"execution_count": 26,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['one', 'one', 'other,', 'on', 'one']"
]
},
"execution_count": 26,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"o_words"
]
},
{
"cell_type": "code",
"execution_count": 31,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"Roads\n",
"One\n",
"By,\n",
"Equally\n",
"Roads\n",
"Trodden\n"
]
}
],
"source": [
"import random\n",
"print(random.choice(r_words).capitalize())\n",
"print(random.choice(o_words).capitalize())\n",
"print(random.choice(b_words).capitalize())\n",
"print(random.choice(e_words).capitalize())\n",
"print(random.choice(r_words).capitalize())\n",
"print(random.choice(t_words).capitalize())"
]
},
{
"cell_type": "code",
"execution_count": 37,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"roads\n",
"on\n",
"be\n",
"equally\n",
"roads\n",
"the\n"
]
}
],
"source": [
"for item in \"robert\":\n",
" print(random.choice([word for word in words if word.startswith(item)]))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"database??\n",
"\n",
"\"r\" -> [\"robert\", \"road\"]\n",
"\"o\" -> [\"other\", \"of\"],\n",
"...\n",
"\n",
"hey database, give me all of the words that start with \"r\", \"o\", \"b\",... \n",
"\n",
"DICTIONARY!"
]
},
{
"cell_type": "code",
"execution_count": 39,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"planet_dist = {\"Mercury\": 0.387, \"Venus\": 0.723, \"Earth\": 1.0, \"Mars\": 1.523}"
]
},
{
"cell_type": "code",
"execution_count": 41,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Earth': 1.0, 'Mars': 1.523, 'Mercury': 0.387, 'Venus': 0.723}"
]
},
"execution_count": 41,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 43,
"metadata": {
"scrolled": true
},
"outputs": [
{
"data": {
"text/plain": [
"dict"
]
},
"execution_count": 43,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"type(planet_dist)"
]
},
{
"cell_type": "code",
"execution_count": 45,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"0.723"
]
},
"execution_count": 45,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_dist[\"Venus\"]"
]
},
{
"cell_type": "code",
"execution_count": 47,
"metadata": {},
"outputs": [
{
"ename": "KeyError",
"evalue": "0.723",
"output_type": "error",
"traceback": [
"\u001b[0;31m---------------------------------------------------------------------------\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m Traceback (most recent call last)",
"\u001b[0;32m<ipython-input-47-6ba718764fb3>\u001b[0m in \u001b[0;36m<module>\u001b[0;34m()\u001b[0m\n\u001b[0;32m----> 1\u001b[0;31m \u001b[0mplanet_dist\u001b[0m\u001b[0;34m[\u001b[0m\u001b[0;36m0.723\u001b[0m\u001b[0;34m]\u001b[0m\u001b[0;34m\u001b[0m\u001b[0m\n\u001b[0m",
"\u001b[0;31mKeyError\u001b[0m: 0.723"
]
}
],
"source": [
"planet_dist[0.723]"
]
},
{
"cell_type": "code",
"execution_count": 49,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 49,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"Mars\" in planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 51,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"False"
]
},
"execution_count": 51,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"Nibiru\" in planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 53,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"True"
]
},
"execution_count": 53,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"\"Nibiru\" not in planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 56,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"planet_dist[\"Jupiter\"] = 5.2"
]
},
{
"cell_type": "code",
"execution_count": 57,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Earth': 1.0, 'Jupiter': 5.2, 'Mars': 1.523, 'Mercury': 0.387, 'Venus': 0.723}"
]
},
"execution_count": 57,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 59,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"planet_dist[\"Jupiter\"] = 5.3"
]
},
{
"cell_type": "code",
"execution_count": 61,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Earth': 1.0, 'Jupiter': 5.3, 'Mars': 1.523, 'Mercury': 0.387, 'Venus': 0.723}"
]
},
"execution_count": 61,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 62,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"planet_dist[\"Jupiter\"] += 2"
]
},
{
"cell_type": "code",
"execution_count": 64,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Earth': 1.0, 'Jupiter': 7.3, 'Mars': 1.523, 'Mercury': 0.387, 'Venus': 0.723}"
]
},
"execution_count": 64,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_dist"
]
},
{
"cell_type": "code",
"execution_count": 65,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"number_words = {0: \"zero\", 1: \"one\", 2: \"two\", 3: \"three\"}"
]
},
{
"cell_type": "code",
"execution_count": 67,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'two'"
]
},
"execution_count": 67,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"number_words[2]"
]
},
{
"cell_type": "code",
"execution_count": 68,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"planet_moons = {\n",
" \"Mercury\": [],\n",
" \"Venus\": [],\n",
" \"Earth\": [\"Moon\"],\n",
" \"Mars\": [\"Phobos\", \"Deimos\"],\n",
" \"Jupiter\": [\"Io\", \"Europa\", \"Ganymede\", \"Callisto\"]\n",
"}"
]
},
{
"cell_type": "code",
"execution_count": 70,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"1"
]
},
"execution_count": 70,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(planet_moons[\"Earth\"])"
]
},
{
"cell_type": "code",
"execution_count": 72,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"4"
]
},
"execution_count": 72,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"len(planet_moons[\"Earth\"][0])"
]
},
{
"cell_type": "code",
"execution_count": 74,
"metadata": {},
"outputs": [],
"source": [
"planet_moons[\"Earth\"].append(\"Allison\")"
]
},
{
"cell_type": "code",
"execution_count": 76,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'Earth': ['Moon', 'Allison'],\n",
" 'Jupiter': ['Io', 'Europa', 'Ganymede', 'Callisto'],\n",
" 'Mars': ['Phobos', 'Deimos'],\n",
" 'Mercury': [],\n",
" 'Venus': []}"
]
},
"execution_count": 76,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"planet_moons"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"what we want to end up with:\n",
"\n",
" {'a': [\"as\", \"above\"],\n",
" 'b': [\"both\", \"bent\"],\n",
" 'c': [\"could\", \"could\", \"claim\"],\n",
" ...}\n"
]
},
{
"cell_type": "code",
"execution_count": 85,
"metadata": {},
"outputs": [],
"source": [
"initials = {}\n",
"\n",
"# look at the first letter of each word\n",
"# check to see if there's already an entry in initials\n",
"# if the first letter is not already a key: add it with an empty list\n",
"# if it is, then add the word to the (list) value\n",
"\n",
"for item in words:\n",
" first_let = item[0].lower()\n",
" if first_let not in initials:\n",
" initials[first_let] = []\n",
" initials[first_let].append(item)\n",
" #print(item, first_let, initials)\n",
" #print()"
]
},
{
"cell_type": "code",
"execution_count": 87,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'a': ['a',\n",
" 'And',\n",
" 'And',\n",
" 'And',\n",
" 'as',\n",
" 'as',\n",
" 'as',\n",
" 'as',\n",
" 'And',\n",
" 'and',\n",
" 'as',\n",
" 'about',\n",
" 'And',\n",
" 'another',\n",
" 'a',\n",
" 'ages',\n",
" 'and',\n",
" 'ages',\n",
" 'a',\n",
" 'and',\n",
" 'And',\n",
" 'all'],\n",
" 'b': ['both',\n",
" 'be',\n",
" 'bent',\n",
" 'better',\n",
" 'Because',\n",
" 'both',\n",
" 'black.',\n",
" 'back.',\n",
" 'be',\n",
" 'by,'],\n",
" 'c': ['could', 'could', 'claim,', 'come'],\n",
" 'd': ['diverged', 'down', 'day!', 'doubted', 'diverged', 'difference.'],\n",
" 'e': ['equally', 'ever'],\n",
" 'f': ['far', 'fair,', 'for', 'first', 'for'],\n",
" 'g': ['grassy'],\n",
" 'h': ['having', 'Had', 'had', 'how', 'hence:', 'has'],\n",
" 'i': ['in',\n",
" 'I',\n",
" 'I',\n",
" 'I',\n",
" 'it',\n",
" 'in',\n",
" 'it',\n",
" 'In',\n",
" 'I',\n",
" 'I',\n",
" 'if',\n",
" 'I',\n",
" 'I',\n",
" 'in',\n",
" 'I---',\n",
" 'I'],\n",
" 'j': ['just'],\n",
" 'k': ['kept', 'knowing'],\n",
" 'l': ['long', 'looked', 'lay', 'leaves', 'leads', 'less'],\n",
" 'm': ['morning', 'made'],\n",
" 'n': ['not', 'no'],\n",
" 'o': ['one', 'one', 'other,', 'Oh,', 'on', 'one'],\n",
" 'p': ['perhaps', 'passing'],\n",
" 'r': ['roads', 'really', 'roads'],\n",
" 's': ['sorry',\n",
" 'stood',\n",
" 'same,',\n",
" 'step',\n",
" 'should',\n",
" 'shall',\n",
" 'sigh',\n",
" 'Somewhere'],\n",
" 't': ['Two',\n",
" 'travel',\n",
" 'traveler,',\n",
" 'To',\n",
" 'the',\n",
" 'Then',\n",
" 'took',\n",
" 'the',\n",
" 'the',\n",
" 'Though',\n",
" 'that',\n",
" 'the',\n",
" 'there',\n",
" 'them',\n",
" 'the',\n",
" 'that',\n",
" 'trodden',\n",
" 'the',\n",
" 'to',\n",
" 'telling',\n",
" 'this',\n",
" 'Two',\n",
" 'took',\n",
" 'the',\n",
" 'travelled',\n",
" 'that',\n",
" 'the'],\n",
" 'u': ['undergrowth;'],\n",
" 'w': ['wood,',\n",
" 'where',\n",
" 'was',\n",
" 'wanted',\n",
" 'wear;',\n",
" 'worn',\n",
" 'way',\n",
" 'way,',\n",
" 'with',\n",
" 'wood,'],\n",
" 'y': ['yellow', 'Yet']}"
]
},
"execution_count": 87,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"initials"
]
},
{
"cell_type": "code",
"execution_count": 99,
"metadata": {},
"outputs": [],
"source": [
"seed_phrase = \"academics\""
]
},
{
"cell_type": "code",
"execution_count": 102,
"metadata": {},
"outputs": [
{
"name": "stdout",
"output_type": "stream",
"text": [
"A\n",
"Could\n",
"As\n",
"Difference.\n",
"Ever\n",
"Morning\n",
"It\n",
"Come\n",
"Stood\n"
]
}
],
"source": [
"acrostic = [random.choice(initials[item]).capitalize() for item in seed_phrase]\n",
"print(\"\\n\".join(acrostic))"
]
},
{
"cell_type": "markdown",
"metadata": {},
"source": [
"### using json!"
]
},
{
"cell_type": "code",
"execution_count": 103,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"animals = open(\"common.json\").read()"
]
},
{
"cell_type": "code",
"execution_count": 105,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"'{\\n \"animals\":\\n [\\n \"aardvark\",\\n \"alligator\",\\n \"alpaca\",\\n \"antelope\",\\n \"ape\",\\n \"armadillo\",\\n \"baboon\",\\n \"badger\",\\n \"bat\",\\n \"bear\",\\n \"beaver\",\\n \"bison\",\\n \"boar\",\\n \"buffalo\",\\n \"bull\",\\n \"camel\",\\n \"canary\",\\n \"capybara\",\\n \"cat\",\\n \"chameleon\",\\n \"cheetah\",\\n \"chimpanzee\",\\n \"chinchilla\",\\n \"chipmunk\",\\n \"cougar\",\\n \"cow\",\\n \"coyote\",\\n \"crocodile\",\\n \"crow\",\\n \"deer\",\\n \"dingo\",\\n \"dog\",\\n \"donkey\",\\n \"dromedary\",\\n \"elephant\",\\n \"elk\",\\n \"ewe\",\\n \"ferret\",\\n \"finch\",\\n \"fish\",\\n \"fox\",\\n \"frog\",\\n \"gazelle\",\\n \"gila monster\",\\n \"giraffe\",\\n \"gnu\",\\n \"goat\",\\n \"gopher\",\\n \"gorilla\",\\n \"grizzly bear\",\\n \"ground hog\",\\n \"guinea pig\",\\n \"hamster\",\\n \"hedgehog\",\\n \"hippopotamus\",\\n \"hog\",\\n \"horse\",\\n \"hyena\",\\n \"ibex\",\\n \"iguana\",\\n \"impala\",\\n \"jackal\",\\n \"jaguar\",\\n \"kangaroo\",\\n \"koala\",\\n \"lamb\",\\n \"lemur\",\\n \"leopard\",\\n \"lion\",\\n \"lizard\",\\n \"llama\",\\n \"lynx\",\\n \"mandrill\",\\n \"marmoset\",\\n \"mink\",\\n \"mole\",\\n \"mongoose\",\\n \"monkey\",\\n \"moose\",\\n \"mountain goat\",\\n \"mouse\",\\n \"mule\",\\n \"muskrat\",\\n \"mustang\",\\n \"mynah bird\",\\n \"newt\",\\n \"ocelot\",\\n \"opossum\",\\n \"orangutan\",\\n \"oryx\",\\n \"otter\",\\n \"ox\",\\n \"panda\",\\n \"panther\",\\n \"parakeet\",\\n \"parrot\",\\n \"pig\",\\n \"platypus\",\\n \"polar bear\",\\n \"porcupine\",\\n \"porpoise\",\\n \"prairie dog\",\\n \"puma\",\\n \"rabbit\",\\n \"raccoon\",\\n \"ram\",\\n \"rat\",\\n \"reindeer\",\\n \"reptile\",\\n \"rhinoceros\",\\n \"salamander\",\\n \"seal\",\\n \"sheep\",\\n \"shrew\",\\n \"silver fox\",\\n \"skunk\",\\n \"sloth\",\\n \"snake\",\\n \"squirrel\",\\n \"tapir\",\\n \"tiger\",\\n \"toad\",\\n \"turtle\",\\n \"walrus\",\\n \"warthog\",\\n \"weasel\",\\n \"whale\",\\n \"wildcat\",\\n \"wolf\",\\n \"wolverine\",\\n \"wombat\",\\n \"woodchuck\",\\n \"yak\",\\n \"zebra\"\\n ]\\n}\\n'"
]
},
"execution_count": 105,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"animals"
]
},
{
"cell_type": "code",
"execution_count": 106,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"import json"
]
},
{
"cell_type": "code",
"execution_count": 113,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"animals_data = json.loads(open(\"common.json\").read())"
]
},
{
"cell_type": "code",
"execution_count": 114,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['aardvark',\n",
" 'alligator',\n",
" 'alpaca',\n",
" 'antelope',\n",
" 'ape',\n",
" 'armadillo',\n",
" 'baboon',\n",
" 'badger',\n",
" 'bat',\n",
" 'bear',\n",
" 'beaver',\n",
" 'bison',\n",
" 'boar',\n",
" 'buffalo',\n",
" 'bull',\n",
" 'camel',\n",
" 'canary',\n",
" 'capybara',\n",
" 'cat',\n",
" 'chameleon',\n",
" 'cheetah',\n",
" 'chimpanzee',\n",
" 'chinchilla',\n",
" 'chipmunk',\n",
" 'cougar',\n",
" 'cow',\n",
" 'coyote',\n",
" 'crocodile',\n",
" 'crow',\n",
" 'deer',\n",
" 'dingo',\n",
" 'dog',\n",
" 'donkey',\n",
" 'dromedary',\n",
" 'elephant',\n",
" 'elk',\n",
" 'ewe',\n",
" 'ferret',\n",
" 'finch',\n",
" 'fish',\n",
" 'fox',\n",
" 'frog',\n",
" 'gazelle',\n",
" 'gila monster',\n",
" 'giraffe',\n",
" 'gnu',\n",
" 'goat',\n",
" 'gopher',\n",
" 'gorilla',\n",
" 'grizzly bear',\n",
" 'ground hog',\n",
" 'guinea pig',\n",
" 'hamster',\n",
" 'hedgehog',\n",
" 'hippopotamus',\n",
" 'hog',\n",
" 'horse',\n",
" 'hyena',\n",
" 'ibex',\n",
" 'iguana',\n",
" 'impala',\n",
" 'jackal',\n",
" 'jaguar',\n",
" 'kangaroo',\n",
" 'koala',\n",
" 'lamb',\n",
" 'lemur',\n",
" 'leopard',\n",
" 'lion',\n",
" 'lizard',\n",
" 'llama',\n",
" 'lynx',\n",
" 'mandrill',\n",
" 'marmoset',\n",
" 'mink',\n",
" 'mole',\n",
" 'mongoose',\n",
" 'monkey',\n",
" 'moose',\n",
" 'mountain goat',\n",
" 'mouse',\n",
" 'mule',\n",
" 'muskrat',\n",
" 'mustang',\n",
" 'mynah bird',\n",
" 'newt',\n",
" 'ocelot',\n",
" 'opossum',\n",
" 'orangutan',\n",
" 'oryx',\n",
" 'otter',\n",
" 'ox',\n",
" 'panda',\n",
" 'panther',\n",
" 'parakeet',\n",
" 'parrot',\n",
" 'pig',\n",
" 'platypus',\n",
" 'polar bear',\n",
" 'porcupine',\n",
" 'porpoise',\n",
" 'prairie dog',\n",
" 'puma',\n",
" 'rabbit',\n",
" 'raccoon',\n",
" 'ram',\n",
" 'rat',\n",
" 'reindeer',\n",
" 'reptile',\n",
" 'rhinoceros',\n",
" 'salamander',\n",
" 'seal',\n",
" 'sheep',\n",
" 'shrew',\n",
" 'silver fox',\n",
" 'skunk',\n",
" 'sloth',\n",
" 'snake',\n",
" 'squirrel',\n",
" 'tapir',\n",
" 'tiger',\n",
" 'toad',\n",
" 'turtle',\n",
" 'walrus',\n",
" 'warthog',\n",
" 'weasel',\n",
" 'whale',\n",
" 'wildcat',\n",
" 'wolf',\n",
" 'wolverine',\n",
" 'wombat',\n",
" 'woodchuck',\n",
" 'yak',\n",
" 'zebra']"
]
},
"execution_count": 114,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"animals_data[\"animals\"]"
]
},
{
"cell_type": "code",
"execution_count": 116,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"['hippopotamus',\n",
" 'ferret',\n",
" 'crocodile',\n",
" 'parrot',\n",
" 'salamander',\n",
" 'llama',\n",
" 'fish',\n",
" 'tiger',\n",
" 'horse',\n",
" 'guinea pig']"
]
},
"execution_count": 116,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"# random animal\n",
"random.sample(animals_data[\"animals\"], 10)"
]
},
{
"cell_type": "code",
"execution_count": 117,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"x = {\"a\": 1, \"b\": 2}"
]
},
{
"cell_type": "code",
"execution_count": 118,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": [
"del x[\"a\"]"
]
},
{
"cell_type": "code",
"execution_count": 119,
"metadata": {},
"outputs": [
{
"data": {
"text/plain": [
"{'b': 2}"
]
},
"execution_count": 119,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [
"x"
]
},
{
"cell_type": "code",
"execution_count": null,
"metadata": {
"collapsed": true
},
"outputs": [],
"source": []
}
],
"metadata": {
"kernelspec": {
"display_name": "Python 3",
"language": "python",
"name": "python3"
},
"language_info": {
"codemirror_mode": {
"name": "ipython",
"version": 3
},
"file_extension": ".py",
"mimetype": "text/x-python",
"name": "python",
"nbconvert_exporter": "python",
"pygments_lexer": "ipython3",
"version": "3.6.1"
}
},
"nbformat": 4,
"nbformat_minor": 2
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment