473,396 Members | 1,886 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

what the complexity of the code

# Program to add two matrices using nested loop

X = [[12,7,3],
[4 ,5,6],
[7 ,8,9]]

Y = [[5,8,1],
[6,7,3],
[4,5,9]]

result = [[0,0,0],
[0,0,0],
[0,0,0]]

# iterate through rows
for i in range(len(X)):
# iterate through columns
for j in range(len(X[0])):
result[i][j] = X[i][j] + Y[i][j]

for r in result:
print(r)
Nov 4 '18 #1
1 1367
rodnaz
3
What's the question? The code runs fine if the 'for j..' and 'result[...' are indented one and two levels respectively. Also indent print(r) Did I miss the question being asked? Perhaps the loss of indenting was just from the paste onto the site? Cheers Nigel
Nov 13 '18 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: MLH | last post by:
I cut a mail function off the m'soft site. Has always worked. However, I would like to include error codes returned by the sendmail Fn and be able to understand what they mean. I had my first...
2
by: sono | last post by:
1. I am looking which HTML CODE is AS GENERAL AS POSSIBLE (i.e. independant of platform and browser). 2. To be more explicit : 2.a) I am writing HTML code which I would like to run on ALL...
0
by: netventuresmarketing | last post by:
Ok so you have already figured out with a name like netventuresmarketing that Im a Internet marketing type trying to teach myself some simple PHP. I purchased a turnkey program to set up a free...
1
by: vbDavidC | last post by:
I want to make backups of a project and email it to myself via email. Even though I have unlimited email storage I don't want to waste any more space than I have to. And I also want to know what...
4
by: Stef Mientki | last post by:
hello, I had a program that worked perfectly well. In this program modules were dynamically added, just by putting the file in a predefined directory. Now one of the interface mechanisms was...
1
by: jerabel | last post by:
what is the code of meter to centimeter in visual basic?
2
by: Debbie Stevens | last post by:
What html code do I use to offer viewers of my webpage different text sizes?
8
by: PRANerd | last post by:
I have a table with 13 fields of information, filed 1 is the item name, and the remaining 12 fields are numerical information about that item. Some of the data in the numerical fields contain...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.