Skip to content

Commit 80be927

Browse files
committed
Merge branch 'master' of https://github.com/tron01/py_scripts
2 parents e37f5f7 + 93842b1 commit 80be927

File tree

6 files changed

+81
-0
lines changed

6 files changed

+81
-0
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: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
#Write a Python program to read a file line by line and store it into a list.
2+
"""
3+
fn = open("demo.txt",'r') #run in thonny (filename,mode)
4+
s= fn.readline() # for read line by line
5+
print(s)
6+
fn.close()
7+
print(fn.closed) #file close status
8+
print(fn.mode) #file mode
9+
print(fn.name) #file name
10+
fo =open("demo2.txt","w")
11+
fo.write("Python is dynamically-typed and garbage-collected \n. It supports multiple programming paradigms")
12+
fo.close()
13+
#replace data in file
14+
f2 =open("demo2.txt","w")
15+
f2.write("Python gdgg")
16+
f2.close()
17+
18+
"""
19+
20+
fn1 =open("demo2.txt","r")
21+
# read multiple line
22+
"""
23+
s1 =fn1.readline()
24+
s2 =fn1.readline()
25+
s3 =fn1.readline()
26+
print(s1)
27+
print(s2)
28+
print(s3)
29+
"""
30+
31+
32+
33+
"""
34+
for x in range(0,len(s1)):
35+
print(s1[x])
36+
fn1.close()
37+
"""
38+
"""
39+
#readlines
40+
s1 =fn1.readlines()
41+
print(s1)
42+
"""
43+
#as list comp
44+
45+
print([line.strip() for line in open('demo2.txt','r')])
46+
47+

C05/demo.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Python is a high-level, general-purpose programming language

C05/demo2.txt

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
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)