With Numpy numpy.ndarray .__ add __ ()
we can add a specific value that is provided as a parameter in ndarray .__ add __ () . A value will be appended to each item in a NumPy array .
Syntax: ndarray .__ add __ ($ self, value, /)
Return: self + value
Example # 1:
In this example, we see that each the array element is added with the value specified as a parameter in the ndarray .__ add __ ()
method. Remember one thing, this will not work for double values.
# import important module into python
import
numpy as np
# make an array with NumPy
gfg
=
np.array ([
1
,
2
,
3
,
4
,
5
] )
# applying the ndarray method .__ add __ ()
print
(gfg .__ add __ (
5
))
Exit:
[6 7 8 9 10]Example # 2:

Output:
[[6 7 8 9 10] [11 10 9 8 7]]
Computer languages have so far been of the ‘interpreted’ or the ‘compiled’ type. Compiled languages (like ‘C’) have been more common. You prepare a program, save it (the debugged version),...
23/09/2020
Learning to code is tremendous fun as you can get instant results, no matter how much more you have to learn. In fact, it’s such fun creating games and programs that it feels effortless once you’r...
23/09/2020
The rate at which we produce data is growing steadily, thus creating even larger streams of continuously evolving data. Online news, microblogs, search queries are just a few examples of these contin...
10/07/2020
Learn how data literacy is changing the world and giving you a better understanding of life's biggest problems in this "Important and Comprehensive" Guide to Statistical Thinking (New York). The bi...
28/08/2021