Yahoo India Web Search

Search results

  1. May 26, 2014 · Avoid unnecessary loops, use map() function. let array = [1,2,3,4,5]; function square(a){ // function to find square. return a*a; } arrSquare = array.map(square); //array is the array of numbers and arrSquare will be an array of same length with squares of every number. You can make the code shorter like this:

  2. I'm new to python and I am trying to make a code to print all the square numbers until the square of the desired value entered by the user. n = raw_input("Enter number") a = 1 while a < n: a = 1 print(a*a) a += 1 if a > n: break When I run this code it infinitely prints "1" ...

  3. What's the fastest way to square a number in JavaScript? function squareIt(number) { return Math.pow(number,2); } function squareIt(number) { return number * number; } Or some other method that I don't know about. I'm not looking for a golfed answer, but the answer that's likely to be shortest in the compiler, on the average.

  4. May 7, 2014 · I'm trying to take a list of numbers, filter out the even numbers and then square those even numbers so that the even numbers in the original list are squared. Here's my code: ArrayList&lt;Long&gt;

  5. May 15, 2015 · squareroot = math.sqrt(start) if self.start > self.stop: raise StopIteration. if squareroot == math.ceil(squareroot): start += 1. But at the moment this is returning None an infinite amount of times. This means the none must be because the StopIteration is being executed even when it shouldn't.

  6. Jan 24, 2014 · I would like to square every value in data, and I am thinking about using a for loop like this: data = rnorm(100, mean=0, sd=1) Newdata = {L = NULL; for (i in data) {i = i*i} L = i return (L)} r. perfect-square. edited Oct 11, 2018 at 9:27. Cœur. 38.5k 26 201 275. asked Jan 24, 2014 at 0:16.

  7. Dec 1, 2013 · Change print square(num); to System.out.println(square(num)); or to square(num); Although, what you're doing makes no sense because you actually print the number in your method as well. Try changing your code to this:

  8. Write a function, square(a), that takes an array, a, of numbers and returns an array containing each of the values of a squared. At first, I had. def square(a): for i in a: print i**2 But this does not work since I'm printing, and not returning like I was asked. So I tried. def square(a): for i in a: return i**2

  9. Quiz: Use a list comprehension to create a list of squared numbers (n*n). The function receives the variables start and end, and returns a list of squares of consecutive numbers between start and ...

  10. Jan 26, 2017 · Nothing wrong with the accepted answer, there is also: df = pd.DataFrame({'a': range(0,100)}) np.square(df) np.power(df, 2) Which is ever so slightly faster: In [11]: %timeit df ** 2. 10000 loops, best of 3: 95.9 µs per loop.

  1. People also search for