During this tutorial we will quickly show how to install and use Julia.
However, there are several videos uploaded to SUNLearn on how to do this.
The questions for the problem set range from easy to hard.
The first question is easiest and then it gets progressively harder.
You should try and complete these questions before the lecture so that you can ask questions.
The fourth question is optional
.
In the tutorial there will be one unseen
question that you will have chance to finish in the lecture.
Before we start with the tutorial, make sure to add the LinearAlgebra
and Random
packages as follows,
import Pkg
Pkg.add("LinearAlgebra")
Pkg.add("Random")
using LinearAlgebra
using Random
Take a few seconds to try and code up an answer to the following question.
This will help you come to grips with the way in which arithmetic operations are defined in Julia.
Determine the value and type of y
given by the following expression
where x = 4
and p = 5
.
Consider a two dimensional array, which we can call x_2d
.
Create an array called int_array
and fill it with five integers between 1 and 15 (this includes both 1 and 15).
Create a for loop that iterates over the elements of int_array
. Inside the for loop use if/else statments to print the following.
"Small"
"Large"
"Eight"
optional
)¶The following question is optional
.
Edit your if/else statement from Question 3 so that if the any of the elements of int_array
is a multiple of 3 ONLY print "Multiple of 3"