1 Study materials

1.1 Basics of computer architecture

Carry out the computer architecture exercises.


1.2 R Variables

Read Chapter 2 of R for Data Science (2e).

Carry out the R variables activities and exercises.

For more details read the help pages for arithmetic operators (?Arithmetic).


2 Activities

2.1 Working with R variables

Refer to the R variables section and perform the following tasks.

2.1.1 Using R as a calculator

  1. Arithmetic operators and operator precedence. Compute 1 + 3 - 5 * 8 / 2 ^ 2 and 1 + (3 - 5) * 8 / 2 ^ 2.

  2. Mathematical functions. Compute \((1.13+0.334)\times\exp(0.9)\)

  3. Built-in constants. Compute \(\sin(\frac{23}{2}*\pi)\).

  4. Scientific notation. Compute the number of hydrogen atoms in 1pg of hydrogen gas.

2.1.2 Storing data in variables using the assignment operator <-

  1. Compute and store the number of hydrogen atoms in a variable x.

  2. Good programming practice. Using descriptive variable names. Compute and store the number of hydrogen atoms in a variable with a descriptive name.

  3. Benefits of variables. Store the mass of hydrogen atoms in a variable mass and Avogadro’s constant in avo. Compute the number of hydrogen atoms. Then, in a separate code chunk, change the mass and recompute.


2.2 Additional exercises

2.2.1 Basics of computer architecture

Watch the basics of computer architecture video and answer the following questions.

  1. Fill in the following table.
Component Function
Random access memory
Execute instructions to compute output from input data
Input devices
Convey the results/output of computation
Secondary storage
  1. What are the tradeoffs between RAM and secondary storage?

  2. How many integers can a memory location with 6 bits hold?

  3. A character is 1 byte long. How many characters can be represented?

2.2.2 R Variables

  1. Insert a code chunk to compute \(2^{3 \times 2 - 6/3}\).

  2. Insert a code chunk to compute \(5.134 \times 10^{-3} + 1.087 \times 10^{-2}\). Use scientific notation.

  3. Compute \(2^{\sin(\frac{3\pi}{2})}\).

  4. Insert a code chunk and do the following. Assign the value 0.3998 to a variable radius. Compute the circumference using the radius variable and assign the value to a new variable, circumference. Print out the value of circumference.

  5. Compute the area of the circle using the radius variable and assign to a third variable area. Print out the area.

  6. Change the radius to \(3.1122 \times 10^4\) and recompute the circumference and area and print their values out.