Python How To Video Pt 4

Python How ToIn this article and video, I’ll show you how to read and write to files using the Python programming language.

If you didn’t watch part one definitely watch Python How to Program Part 1 first!

In this video, I also use the Eclipse IDE for coding, instead of IDLE. If you want to know how to install it (It’s Free), watch this tutorial Eclipse The Free IDE.

If you have any questions leave them in the comment section below.

The code from the video tutorial can be found on this page, after the video.

NOTE: For best view of video click the HD and Full Screen Buttons


Here is the Complicated Code from the Video

bestStudent = {}
f = open(‘studentgrades.txt’)
for line in f:
name, grade = line.split()
bestStudent[grade] = name


bestStudentStr = “”

for i in sorted(bestStudent.keys(), reverse=True):
print(bestStudent[i] + ‘ scored a ‘ + i)
bestStudentStr += bestStudent[i] + ‘ scored a ‘ + i + ‘\n’

bestStudentStr = ‘\nThe Best Students Ranked\n\n’ + bestStudentStr


outToFile = open(‘studentrank.txt’, mode=’w’, encoding=’utf-8′)


print(‘Finished update’)

Leave a Reply

Your email address will not be published.