Question

012345 102345 Complete the following code to iterate through the keys and values of the fantastic beasts hash. 1- fantastic beasts f 2 octopuses tentacles, 3 dolphins fins 4 rhinos horns 6 # Replace ??? below with appropriate values 8 9- fantastic_beasts.?2? do 22?, 22Pl Run 10 11 12 #{animal) #{attribute} puts end have Reset 12 In the following definition of the add method, what can be said about the variable named x? 1- def add(x, y)

0 0
Add a comment Improve this question Transcribed image text
Answer #1

fantastic_beasts = {

"octopuses" => "tentacles",

"dolphins" => "fins",

"rhinos" => "horns"

}

# Replace ??? below with appropriate values

fantastic_beasts.each do |animal, attribute|

puts "#{animal} have #{attribute}"

end

# fantastic_beasts.each is used for traverse each element in fantastic_beats.

# do |animal, attribute| is used for fetch each key and value of fantastic_beasts

Add a comment
Know the answer?
Add Answer to:
012345 102345 Complete the following code to iterate through the keys and values of the fantastic...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT