Publications by Harold Nelson

Notes on Iteration

28.01.2020

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...

2390 sym R (1192 sym/18 pcs)

Files Exercises

06.02.2020

Files Exercises Harold Nelson 9/29/2020 Ex1 You have a file “Pride and Prejudice.txt” in a folder “Pride and Prejudice”. In that folder, create a jupyter notebook and write a program to read the contents of the file line by line into a list called lines. In the reading loop, count the number of lines you read. Compare this with the len...

1213 sym R (2171 sym/20 pcs)

Compare

07.02.2020

Notes for Feb 12 Libraries and Data library(tidyverse) ## ── Attaching packages ─────────────────────────────────────────────────────────────────────── tidyverse 1.3.0 ── ## ✓ ggplot2 3.2.1 �...

743 sym R (3053 sym/27 pcs) 3 img

Dictionary Exercises

11.02.2020

Dictionary Exercises Harold Nelson 2/10/2020 library(reticulate) 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) ## {'Dick': 150, 'Joe': 175, 'Tom': 190} Ex2 Add Harry, who weighs 180 pounds to the dictionary and print t...

1364 sym R (1433 sym/40 pcs)

Counting with Dicts

11.02.2020

Counting with Dicts Harold Nelson 9/30/2020 Counting Occurrences There is a basic pattern for counting using a dictionary. Let’s use the string ‘Mississippi’ to demonstrate. s = 'Mississippi' count_dict = {} for c in s: if c in count_dict: count_dict[c] = count_dict[c] + 1 else: count_dict[c] = 1 # Let's look at ...

1998 sym R (4716 sym/32 pcs)

Build Nat0718

24.02.2020

Load Libraries library(tidyverse) Get the Data Nat0718 <- read_csv("Nat0718.csv") ## Parsed with column specification: ## cols( ## Region = col_character(), ## Race = col_character(), ## Age = col_character(), ## Year = col_double(), ## Births = col_character(), ## Fpop = col_character() ## ) Nat0718 %>% mutate(Births = as.numeric...

53 sym R (1154 sym/7 pcs) 1 img

Set Exercises 2

02.03.2020

Set Exercises 2 Nelson 3/2/2020 library(reticulate) Review Consider Problem 4 on page 48 of the finite mathematics text. Write the code which generates all 256 possible strings which can be made using the letters of “STOP”. Place them in a list named “words”. Print the list and its length. Answer words = [] for l1 in "STOP": for ...

1243 sym R (3422 sym/15 pcs)

Exercises on Relationships

11.04.2020

Exercises on Relationships Harold Nelson 4/11/2020 Introduction This set of exercises is to develop your skill in applying numerical and graphical tools in examining relationships between two variables. Each exercise presents two variables. You need to classify each variable as to type. Is it quantitative or categorical? You need to consider t...

8071 sym R (11811 sym/38 pcs) 6 img

Simple Probability Computations

19.04.2020

Simple Probability Computation Harold Nelson 4/19/2020 Basic Concepts of Probability An event is a set of possible outcomes of an experiment.The probability of an event is what we expect its relative frequency to approach as we run the experiment a large number of times.These values can arise from several sources. Probabilities are always numb...

3427 sym R (413 sym/18 pcs)

Sampling Distribution of the Mean

10.05.2020

Sampling Distribution of the Mean Harold Nelson 5/3/2020 This set of exercises focuses on the sampling distribution of the mean. It assumes that you have worked through slides 169 - 171 in Module 12 of the CMU Probability and Statistics course. What does the summary on slide 171 say about the sampling distribution of the mean? Answer The mea...

5728 sym R (2972 sym/40 pcs) 2 img