-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathcalc_cumm_sum.py
26 lines (24 loc) · 1.06 KB
/
calc_cumm_sum.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
#Write a NumPy program to calculate cumulative sum of the elements along a given axis,
#sum over rows for each of the 3 columns and sum over columns for each of the 2 rows of a given 3x3 array.
import numpy as np
x = np.array([[1,2,3], [4,5,6]])
print("Original array: ")
print(x)
print("Cumulative sum of the elements along a given axis:")
r = np.cumsum(x)
print(r)
print("\nSum over rows for each of the 3 columns:")
r = np.cumsum(x,axis=0)
print(r)
print("\nSum over columns for each of the 2 rows:")
r = np.cumsum(x,axis=1)
print(r)
"""
👋 Hi, I’m @aarushinair - Aarushi Nair (she/her/ella)
👀 I’m a Computer Science Engineering Student
💞️ I’m looking to collaborate on #java, #python, #R, #applicationdevelopment
🌱 #GirlsWhoCode #WomenInTech #WomenInIT #WomenInSTEM #CyberSecurity #QuantumComputing #BlockChain #AI #ML
📫 How to reach me: https://www.linkedin.com/in/aarushinair/
👩🏫 YouTube Channel - Code with Aarushi : https://www.youtube.com/channel/UCKj5T1ELHCmkGKujkpqtl7Q
🙋 Follow me on Twitter: https://twitter.com/aarushinair_
"""