Question: Write a Python driver program that uses your getnlines() function from Question 3 that reads the file path from the command line using sys.argvas we

Write a Python driver program that uses your getnlines() function from Question 3 that reads the file path from the command line using sys.argvas we discussed in class recently.

You must store your getlines() function in a file called getnlines.py.

Then in your driver program, you must import the getlines() function from this file.

You must call your driver program getnlines_driver.py.

When you determine the number of lines using getnlines() in the provided file, then your program should just print this value out to the screen:

n = getnlines( filepath ) print( n )

When you then run your program from the command line (in a terminal) or using the (!) magic in a Jupyter Lab code cell, you should get the following result.

>>> python getnlines_driver.py news.dat!python getnlines_driver.py news.dat 12

%%file news.dat (CNN)Betsy Williams recalls being awoken just after 4:30 a.m. Friday by what sounded like gunfire from an automatic weapon.

After Williams called 911 and police cordoned off Second Avenue in downtown Nashville, a "computerized message" from a parked RV captured her attention.

"Evacuate now," Williams remembers the female voice saying -- over and over again.

Williams told CNN hours after the vehicle exploded, injuring three, that she and wife Kim clearly heard another message emanating from the RV. It was a countdown.

#>>> getnlines( 'news.dat' ) #12

!python getnlines_driver.py news.dat

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!