Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Find the tail and head (tail_head) using PYTHON : This is the prompt and my code for the first part, i only need help writing

Find the tail and head (tail_head) using PYTHON: This is the prompt and my code for the first part, i only need help writing the tail_head, tail_head FLAG with input options, and IF statement (less than 2 times number of lines to skip output entire file)

Write a complete PYTHON program with prompts for the user to get the main text file (checks that it exists, and if not, output an error message and stop), for any possible flags (flags allows the user to change the default conditions or to use the defaults, and for any other input that this program may need from the user: split has an option of naming the smaller files. Your program will open the input file once only and using seek(0) to avoid re-opening the file will cost all points

MY CODE FOR OPENING AND ERROR CHECK:

image

---------------tail_head requirements--------------

image

import os file = input ("Enter the filename you want to open:") if os.path.isfile(file): fin = open(file, "r") read = fin.read() 0 print (read) fin.close() else: print("Error")

Step by Step Solution

3.36 Rating (143 Votes )

There are 3 Steps involved in it

Step: 1

The program is as below Save it in file tailheadpy import os file inputEnter the filename you want to open flag nooflines 5 if ospathisfilefile fin op... blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Income Tax Fundamentals 2013

Authors: Gerald E. Whittenburg, Martha Altus Buller, Steven L Gill

31st Edition

1111972516, 978-1285586618, 1285586611, 978-1285613109, 978-1111972516

More Books

Students also viewed these Electrical Engineering questions

Question

Solve Utt = cUTT 0

Answered: 1 week ago

Question

What courses does he/she teach?

Answered: 1 week ago