Quiz: Useful Utility Programs

Review your understanding of this section by attempting the following short quiz.

1

What is the output of the following code?

array = [1.0, 1.2, 1.5, 1.7, 2.0]
array.each_with_index do |n, i|
  puts "#{n}, #{i}"
end
A)
1.0, 0

1.2, 0

1.5, 0

1.7, 0

2.0, 0
B)
1.0, 0

1.2, 1

1.5, 2

1.7, 3

2.0, 4
C)
1.0, 1

1.2, 2

1.5, 3

1.7, 4

2.0, 5
D)
0, 1.0

1, 1.2

2, 1.5

3, 1.7

4, 2.0
Question 1 of 50 attempted

Get hands-on with 1400+ tech skills courses.