Skip to content

Instantly share code, notes, and snippets.

@rozer007
Created December 15, 2021 08:11
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save rozer007/b1c73a8d8d7f27e9c12b32d12d8cf514 to your computer and use it in GitHub Desktop.
Save rozer007/b1c73a8d8d7f27e9c12b32d12d8cf514 to your computer and use it in GitHub Desktop.
Arrays and tuples in Julia
Q1. What is the difference between an array and tuples?
ans: Arrays are mutables ordered collection of items whereas tuples are immutables ordered collection of items.
Q2. What is a Array constructor in julia?
ans: Array constructor is function which will help us to create an array of any size or dimension.
Q3.What is the use of splice!() function?
ans: Splice function can be use to remove and add elements in an array.
Q4.What are named tuples?
ans: These are tuples whose elements can be access by a name instead of a index.
Q5.Can an Array and a tuples can stores items of different data types?
ans: Yes an array and a tuples can store items of different data types.
Q1.What will be the output of this statement
a4 = [1,2,"hi",3,4,5,4]# Put values starting at 2nd index
splice!(a4, 2:1, [8,9])
println(a4)
a) Error
b) [1,8,9,"hi",3,4,5,4]
c) [1, 8, 9, 2, "hi", 3, 4, 5, 4]
d) None of the above
ans: c)
Q2.What is the correct way to find the maximum elements in an array?
a) max array_name
b) array_name.max
c) max(array_name)
d) maximum(array_name)
ans: d)
Q3.what will be the output of this statement?
a7 = [1 2 3; 4 5 6]
println(a7[1,2:end])
a) [1 2 3]
b) [5 6]
c) [2 3]
d) [4 5 6]
ans: d)
Q4.what will be the output of this statement
t3=(a=(1,2,"A"),b=(3,"B","C"))
println(t3.a)
a) Error
b) (1,2,"A")
c) (3,"B","C")
d) None of the above
ans: c)
Q5.What will be the output of this statement?
a9 = collect(2:-1:5)
println(a9)
a) [5 4 3 2 1]
b) error
c) []
d) [2 -1 -2 -3 -4]
ans: c)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment