Matrix output of txt file from Python

Asked 2 years ago, Updated 2 years ago, 77 views

3 2
1.0     2.0     3.0
4.0    5.0    6.0
3 2
1.0    2.0    3.0
4.0    5.0    6.0

I want to call the intxt file Python and print out two matrices and find the sum of the two matrices.

A=

1.0 2.0 3.0

4.0 5.0 6.0

I hope it comes out like this

python matrix txt

2022-09-20 10:28

1 Answers

file = open(????)
values = [[value for value in line.split()] for line in file]

Thank you.


2022-09-20 10:28

If you have any answers or tips


© 2024 OneMinuteCode. All rights reserved.