Question 1

x <- 1.1
a <- 2.2
b <- 3.3
#question a
z <- x^a^b
print(z)
## [1] 3.61714
#question b
z <- (x^a)^b
print(z)
## [1] 1.997611
#question c
z <- 3*x^3 + 2*x^2 + 1
print(z) 
## [1] 7.413

Question 2

#question a
c(seq(1,8),seq(7,1))
##  [1] 1 2 3 4 5 6 7 8 7 6 5 4 3 2 1
#question b
my_vec <- 1:5
rep(x=my_vec, times=my_vec)
##  [1] 1 2 2 3 3 3 4 4 4 4 5 5 5 5 5
#question c
my_vec2 <- 5:1
rep(x=my_vec2, times=my_vec)
##  [1] 5 4 4 3 3 3 2 2 2 2 1 1 1 1 1

Question 3

random <- runif(2)
x <- random[1]
y <- random[2]
theta <- atan(y/x)
r <- sqrt(x^2 + y^2)

Question 4

queue <- c("sheep","fox","owl","ant")
queue <- c(queue,"serpant") #a
queue <- c(queue[-1]) #b
queue <- c("donkey", queue)#c
queue <- c(queue[-which(queue == "serpant")]) #d
queue <- queue[-which(queue == "owl")] #e
pos_ant <- which(queue == "ant")
queue <- c(queue[1:(pos_ant-1)], "aphid", queue[pos_ant:length(queue)]) #f
pos_aphid <- which( queue == "aphid") #g
print(pos_aphid)
## [1] 3

Question 5

start <- 1:100
vector <- which(start %% 2 != 0 & start %% 3 != 0 & start %% 7 != 0)
print(vector)
##  [1]  1  5 11 13 17 19 23 25 29 31 37 41 43 47 53 55 59 61 65 67 71 73 79 83 85
## [26] 89 95 97