Skip to content

Commit 93842b1

Browse files
committed
co5p2
1 parent 8fbf8f2 commit 93842b1

File tree

5 files changed

+34
-4
lines changed

5 files changed

+34
-4
lines changed

C05/c05_p2.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
#Python program to copy odd lines of one file to other***
2+
3+
f1=open("f1.txt",'r')
4+
f2=open("f2.txt",'w')
5+
l1 =f1.readlines()
6+
7+
8+
for i in range(0,len(l1)):
9+
if i%2 ==0:
10+
f2.write(l1[i])
11+
f2.close()
12+
f3=open("f2.txt",'r')
13+
cont =f3.readlines()
14+
print(cont)
15+
f3.close()

C05/co5_p1.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@
4040
s1 =fn1.readlines()
4141
print(s1)
4242
"""
43-
#as list comp
43+
#as list comp
4444

4545
print([line.strip() for line in open('demo2.txt','r')])
4646

C05/demo2.txt

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
1-
1.Python is dynamically-typed and garbage-collected
2-
2.It supports multiple programming paradigms
3-
3.Object-oriented and functional programming
1+
Python is dynamically-typed and garbage-collected
2+
It supports multiple programming paradigms
3+
Object-oriented and functional programming
4+
Python is dynamically-typed and garbage-collected
5+
It supports multiple programming paradigms
6+
Object-oriented and functional programming
7+
Python is dynamically-typed and garbage-collected
8+
It supports multiple programming paradigms
9+
Object-oriented and functional programming

C05/f1.txt

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
1
2+
2
3+
3
4+
4
5+
5
6+
6

C05/f2.txt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
1
2+
3
3+
5

0 commit comments

Comments
 (0)