Prog Exercises, page340 -2,7,9,10
6.2 File Head Display
Write a program that asks the user for the name of a file. The program should display only the
first five lines of the file's contents. If the file contains less than five lines, it should display the
file's entire contents.
User should prepare a text file like the following in the current directory. If not, user should writ
down the path to the file.
mytest.txt
one
two
three
four
five
six
seven
eight
nine
ten
Python 3.8.3 (tags/v3.8.3:6f8c832, May 13 2020, 22:37:0
D64)] on win32
Type "help", "copyright", "credits" or "license()" for
>>
= RESTART: C:\Users\zchen\Documents\Mercy\ProgramCS\CI:
_ism-268449\Python 4e Solutions Manual\Solutions Manua.
Exercise 6-2.py
Enter the name of the file: test.txt
one
two