File tree Expand file tree Collapse file tree 6 files changed +50
-0
lines changed Expand file tree Collapse file tree 6 files changed +50
-0
lines changed Original file line number Diff line number Diff line change 1+ Hello World!
2+ My name is Ashwin Hegde, I work as a Software Engineer
3+ My primary language is JavaScript and Secondary language is Python
4+ Python is needed for scripting, Machine Learning and Quantum Programming
Original file line number Diff line number Diff line change 1+ # Open terminal > python3 read.py
2+ # Start typing below commands and see the output
3+
4+ with open ('hello.txt' ) as f :
5+ data = f .read ()
6+ print (data )
7+ f .closed
Original file line number Diff line number Diff line change 1+ # Open terminal > python3 readline.py
2+ # Start typing below commands and see the output
3+
4+ f = open ('hello.txt' , 'r' )
5+ print (f .readline ())
6+ print (f .readline ())
7+ print (f .readline ())
8+
Original file line number Diff line number Diff line change 1+ Hello World! My name is Ashwin
Original file line number Diff line number Diff line change 1+ # Open terminal > python3 seekTell.py
2+ # Start typing below commands and see the output
3+
4+ f = open ('sample.txt' , 'r' )
5+
6+ f .seek (8 , 0 ) # 0 mean beginning of the file
7+ print (f .read ())
8+
9+ print ('\n \n ' )
10+
11+ # f.seek(8, 1) # 1 mean current position
12+ # print(f.read())
13+
14+ # print('\n\n')
15+
16+ # f.seek(-3, 2) # 2 mean end of the file
17+ # print(f.read())
18+
Original file line number Diff line number Diff line change 1+ # Open terminal > python3 write.py
2+ # Start typing below commands and see the output
3+
4+ fw = open ('hello.txt' , 'a' )
5+ totalWrittenChar = fw .write ('\n Python is needed for scripting, Machine Learning and Quantum Programming' )
6+ print ('Total written characters are ' + repr (totalWrittenChar ))
7+ fw .close ()
8+
9+ with open ('hello.txt' ) as fr :
10+ data = fr .read ()
11+ print (data )
12+ fr .close ()
You can’t perform that action at this time.
0 commit comments