diff --git a/01_first_hello/Results.jl b/01_first_hello/Results.jl new file mode 100644 index 0000000000000000000000000000000000000000..7aa4912f2cc029f117ec12935c4407da15dd7c17 --- /dev/null +++ b/01_first_hello/Results.jl @@ -0,0 +1,51 @@ +""" +Results of the exercises in the julia course: FirstSteps.jl +""" + +# Please set your working directory +swd("/home/ev20kube/Dokuments/Julia/orWehreverYourProjectIs") + +# What is the purpose of an apostrophe? (‘) +# press ? in the REPL and find out that it is a conjugate transposition operator :) + +# Update your packages +# press ] in the REPL and then tip 'update' +# or tip Pkg.update() in the REPL + +# install packages +# 1. use the package manager in the REPL: ]add "Plots" +# install pkg in the REPL: using Pkg; Pkg.add("Distributions") + +# Build an array with 20 normal distributed numbers +x = randn(1000) +# How would you make a histogram with 1000 random numbers? +import Pkg +using Plots +histogram(randn(1000)) + +#If a is set as a=true and afterwards b is set to b=!!!!a then what is the value of b? (true, false, or error?) +a = true +b = !!!!a + +#Build an array with 10 random numbers between 1 and 10 +a = rand(1:10,10) +println(a) +# print values smaller than 5, with the text: +# “The value … is smaller than 5” +for i in 1:length(a) + if a[i] < 5 + println("The value $(a[i]) is smaller than 5") + end +end + +# Build an function that only print x, y, z if the values of all variables are not 0. +# In the case they are all 0, the function should print “Origin”. + +function coordinates(x, y, z) + if x==0 && y==0 && z==0 + println("origin") + else + println("($x, $y, $z)") + end +end +coordinates(0,0,2)