Publications by Harold Nelson
List Exercises 1
List Exercises 1 Harold Nelson 9/24/2020 Exercise Create and print a list called west_coast containing the names of the states on the west coast of the US. Note there are four. Answer west_coast = ['Alaska','Washington','Oregon','California'] print(west_coast) ## ['Alaska', 'Washington', 'Oregon', 'California'] Exercise Use a for loop to pri...
997 sym R (1241 sym/24 pcs)
Exercises on Strings
Exercises on Strings Harold Nelson 9/22/2020 Exercise 1 Create a string, my_name, containing your name including your first name and last name separated by a single blank space. Then put the second character of your name in the variable second and print second. my_name = "Harold Nelson" second = my_name[1] print(second) ## a Exercise 2 Compu...
3011 sym R (1189 sym/36 pcs)
Notes Sep 17
Data load("~/Dropbox/Documents/SMU/CSC 360-530/cdc.Rdata") load("~/Dropbox/Documents/Pierce/Spring 20 146/OAW.Rdata") load("county.rda") Libraries library(tidyverse) ## ── Attaching packages ──────────────────────────────────────────────────�...
704 sym R (2967 sym/30 pcs) 6 img
Iteration Exercises
Iteration Exercises Harold Nelson 1/28/2020 Exercise 1 What does the following python program print? i = 0 while i < 5: i = i + 1 print(i) Solution i = 0 while i < 5: i = i + 1 print(i) ## 1 ## 2 ## 3 ## 4 ## 5 Exercise 2 Think of this code as one of a number of variations on a theme. The loop variable i could be initialized...
2663 sym R (1638 sym/26 pcs)
Notes on Python Functions
Notes on Functions Harold Nelson 9/14/2020 Basic Builtin Functions There are many functions available to you as soon as you start python. You have used the following and perhaps others: int() float() str() type() These all have the fundamental property that mathematicians require a function. If you put in the same input, the output of the fu...
4028 sym R (707 sym/28 pcs)
Logical Values
Logical Values Harold Nelson 9/12/2020 Video is at https://www.youtube.com/watch?v=2lbj58zB7bc These notes are designed to follow the Datacamp course Intermediate R. They include some details that I want to emphasize or extra points that I consider worth mentioning. This particular set focuses on logical values, the first chapter of the cours...
4578 sym R (1990 sym/32 pcs)
Dicts 3 - Challenges
Dict Challenges Harold Nelson 9/30/2020 Ex1 Create a fruitful function squares(n). It’s only parameter is a positive integer. It returns a dictionary. The keys in this dictionary are the integers between 1 and n inclusive. The values are the squares of the keys. Test your function with the value 20. Answer def squares(n): result = {} ...
558 sym R (307 sym/2 pcs)
Dicts 1
Dicts 1 Harold Nelson 9/30/2020 Ex1 Create a dictionary to record the weights of Joe (175), Tom (190), and Dick (150). Print the dictionary. Answer adict = {"Joe":175,"Tom":190,"Dick":150} print(adict) ## {'Joe': 175, 'Tom': 190, 'Dick': 150} Ex2 Add Harry, who weighs 180 pounds to the dictionary and print the new dictionary. Answer adict["...
872 sym R (790 sym/23 pcs)
Logical Expressions
Logical Expressions Harold Nelson 10/7/2020 This may be your first real experience with a mathematical system that doesn’t involve numbers. The atomic elements in this system are statements instead of numbers. Instead of addition and multiplication, we have conjunction (and) and disjunction (or). If \(x\) is a number, we encounter \(-x\). If...
4468 sym R (2369 sym/36 pcs)
Total Fertility Rate
Total Fertility Rate library(tidyverse) load("Nat0718.Rdata") Computing Total Fertility Rate Start with Nat0718. Look at the data for one combination of Race, Year, and Region.Just look at Age and Rate. Select Whites in the Northeast in 2018. Answer onecell = Nat0718 %>% filter(Race == "White", Region == "NE", Year == 2018) %>% select(Ag...
1044 sym R (842 sym/10 pcs) 1 img