Question

Please answer as soon as possible What's the contents of newNumbers after the following code is...

Please answer as soon as possible

What's the contents of newNumbers after the following code is executed?

val numbers = Array(2.5, 1, 3.2, 9.3, 2, 9, 1.5)
val newNumbers = numbers.map(_.toInt)

Homework Answers

Answer #1

According to the code provided above,

The newNumbers will get a map of integer values after conversion of float to int by toInt method.

Explanation:

  • Here, we have array of float value elements in the variable numbers
  • We have declared a new map variable newNumbers which has the statement to convert float to int values
  • newNumbers = numbers.map(_.toInt)
  • map function will get all values from the array numbers.
  • And then converts all float values to int
  • newNumbers = (2, 1, 3, 9, 2, 9, 1)

I hope the above information and explanation will help you out to understand!

Please comment if you have any queries/errors!

Thank you!

Know the answer?
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
Similar Questions
Please answer as soon as possible Consider the function doIt defined as follows: def doIt(numbers: Array[Double],...
Please answer as soon as possible Consider the function doIt defined as follows: def doIt(numbers: Array[Double], x: Double, y: Double) = numbers.filter( (number: Double) => number >= x - y && number <= x + y ) If numbers is: numbers = Array(2.5, 1, 3.2, 9.3, 2, 9, 1.5) What is returned by doIt(numbers, 2, 3)?
Please I need The right answer for this question as soon as possible. A sag vertical...
Please I need The right answer for this question as soon as possible. A sag vertical curve (equal tangent) has PVI at station 212+00 and elevation 540.75 ft. The initial grade is -2.5% and the final grade is +4.5%. The length of the curve is 900 ft. Determine the following, 1. Stationing of the low point, PVC, and PVT. 2. Elevation at station 213+00, PVC, low point, and PVT.
PLEASE, I NEED THE RIGHT ANSWER FOR THIS QUESTION AS SOON AS POSSIBLE PLEASE. (THE ANSWER...
PLEASE, I NEED THE RIGHT ANSWER FOR THIS QUESTION AS SOON AS POSSIBLE PLEASE. (THE ANSWER MUST BE NOT MORE THAN 2 TO 3 SENTENCES) THANK YOU IN ADVANCE!! what does a critical v/c ratio (X) of 0.9 mean for an intersection? (BE CLEAR AND SPECIFIC)
Please answer the following as soon as possible. Thank you. Add the top method in class...
Please answer the following as soon as possible. Thank you. Add the top method in class Stack to the following python code which returns the top item of the stack. Test it. Design top() method using a single queue as an instance variable, and only constant additional local memory within the method bodies. python code: class Stack: def __init__(self): self.q = Queue() def is_empty(self): return self.q.is_empty() def push(self, data): self.q.enqueue(data) def pop(self): for _ in range(self.q.get_size() - 1): dequeued =...
(Subject is psychology of learning) PLEASE ANSWER AS SOON AS POSSIBLE!! 1.) Learning has been demonstrated...
(Subject is psychology of learning) PLEASE ANSWER AS SOON AS POSSIBLE!! 1.) Learning has been demonstrated to occur in humans beginning: A. at about 25 weeks gestational age. B. at birth. C. at about 36 weeks gestational age. D. about a week after birth. 2.)In elderly people, skill learning: A. is as fast as young adults. B. takes longer than in young adults. C. is slow but less error-prone than in young adults. D. declines even for highly practiced skills....
Draw a memory diagram of the variables of the following code after the execution of the...
Draw a memory diagram of the variables of the following code after the execution of the code. Please draw in form of array auto x = 3, y = -1; ++x; y--; auto z = 2 * (x + y); x = z / y; y = 1 - x;
CAN YOU PLEASE ANSWER AS SOON AS POSSIBLE AND PLEASE ANSWER ALL QUESTIONS THANK YOU 1/...
CAN YOU PLEASE ANSWER AS SOON AS POSSIBLE AND PLEASE ANSWER ALL QUESTIONS THANK YOU 1/ Create a short paragraph using the following terms: sound, pinna, auditory canal, tympanic membrane, ossicles, middle ear, oval window. 2/ Why cone receptors are able to send information about different frequencies of light? 3/In your own words, explain one way in which neuroplasticity allows learning and memory to occur 4/ Sleep is a behavioral state and play a key role in cognition. So how...
Please answer as soon as possible. No explanation needed. 1. True/False Digital signatures provide non-repudiation True...
Please answer as soon as possible. No explanation needed. 1. True/False Digital signatures provide non-repudiation True False 2. Ture/False RSA is a network communications protocol True False 3. True/False Digital signatures use symmetric key cryptography True False 4. True/False The RSA encryption algorithm uses prime numbers to perform the encryption. True False 5. True/False Hashing Algorithms are commonly used for encryption and decryption True False 6. In a XOR comparison of 2 bits: 0 XOR 1 results in a: 0...
Please answer as soon as possible: search for new robotics systems , write one page description...
Please answer as soon as possible: search for new robotics systems , write one page description of such systems and include any link or reference to such system. It is necessary to have references.
CAN YOU PLEASE ANSWER ALL QUESTIONS AND PLEASE ANSWER AS SOON AS POSSIBLE THANK YOU 1....
CAN YOU PLEASE ANSWER ALL QUESTIONS AND PLEASE ANSWER AS SOON AS POSSIBLE THANK YOU 1. Frequency selectivity of the basilar membrane changes when the sound intensity is changed: a. True b. False 2. Which structure is the first relay nucleus for taste? Insula Nucleus of the solitary tract Red nucleus Pineal gland 3. How does sensory information reach the amygdala? a. Through the ventral thalamus and primary-association cortices b. Through a subcortical route from the dorso-medial thalamus c. Through...
ADVERTISEMENT
Need Online Homework Help?

Get Answers For Free
Most questions answered within 1 hours.

Ask a Question
ADVERTISEMENT