Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Support
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
T
taskB_inlab
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
SHAH DEVANSH
taskB_inlab
Commits
b5384dd3
Commit
b5384dd3
authored
Aug 23, 2016
by
ARCHIT GUPTA
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
added part 3
parent
ff8b9eac
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
+32
-0
task3.py
task3.py
+32
-0
No files found.
task3.py
0 → 100644
View file @
b5384dd3
#open the file in read mode
fo
=
open
(
"matrix.txt"
,
"r"
)
#initialsing a list for reading file
mat
=
[]
for
line
in
open
(
'matrix.txt'
)
.
readlines
():
mat
.
append
(
map
(
int
,
line
.
split
()))
#no of rows and columns
row
=
mat
[
0
][
0
]
col
=
mat
[
0
][
1
]
#initialising a 2D array for storing matrix
matrix
=
[]
#initialising with correct size
matrix
=
[[
0
for
i
in
range
(
row
)]
for
j
in
range
(
col
)]
matrix
=
[[
mat
[
j
+
1
][
i
]
for
i
in
range
(
col
)]
for
j
in
range
(
row
)]
#transpose matrix
matrix2
=
[[
mat
[
i
+
1
][
j
]
for
i
in
range
(
row
)]
for
j
in
range
(
col
)]
#writing in file
foo
=
open
(
'transpose.txt'
,
'w'
)
foo
.
write
(
str
(
col
))
foo
.
write
(
' '
)
foo
.
write
(
str
(
row
))
foo
.
write
(
'
\n
'
)
for
i
in
range
(
row
):
for
j
in
range
(
col
):
foo
.
write
(
str
(
matrix2
[
i
][
j
]))
foo
.
write
(
' '
)
foo
.
write
(
'
\n
'
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment