Trusted answers to developer questions

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

The **sqrt()****function** in NumPy computes the non-negative square root of each element of an input array.

numpy.sqrt(x, /, out=None, *, where=True)

Syntax for the sqrt() function

The `sqrt()`

function takes the following parameter values:

**x**

: This represents an input array of values. This is a required parameter. **out**

**where**

: This is the condition over which the input is being broadcast. At a given location where this condition is `True`

, the resulting array will be set to the `ufunc`

result. Otherwise, the resulting array will retain its original value. This is an optional parameter. ****kwargs**

: This represents other keyword arguments. This is an optional parameter. The `sqrt()`

function returns an array of the same shape as the input array passed to it. This array holds the positive square root of the elements in it.

import numpy as np# creating an input array of complex valuesx = np.array([1, 4, 9, 16, 25, 36])# implementing the sqrt() functionmyarray = np.sqrt(x)print(x)print(myarray)

Implementing the sqrt() function

- Line 1
**:**We import the`numpy`

module. - Line 4:
`x`

, with complex values using the`array()`

function. - Line 7
**:**We implement the`sqrt()`

function on the input array and assign the result to a variable,`myarray`

. - Line 9
**:**We print the variable`x`

. - Line 10: We print
`myarray`

.

RELATED TAGS

numpy

python

communnitycreator

CONTRIBUTOR

Onyejiaku Theophilus Chidalu

Grokking Modern System Design Interview for Engineers & Managers

Ace your System Design Interview and take your career to the next level. Learn to handle the design of applications like Netflix, Quora, Facebook, Uber, and many more in a 45-min interview. Learn the RESHADED framework for architecting web-scale applications by determining requirements, constraints, and assumptions before diving into a step-by-step design process.

Keep Exploring

Related Courses