Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a Python 2.7.2 script that does the following: Opens the disk file sequence.txt; the format of this file is one integer value per line.

Write a Python 2.7.2 script that does the following:

Opens the disk file "sequence.txt"; the format of this file is one integer value per line.

Determines if there exists anywhere in the file an "acceptable" sequence using a=3 and epsilon=7.

If an acceptable sequence is found, print Accept X to the Python console, where X is the length of the sequence found.

If an acceptable sequence is not found, print BOGUS to the Python console.

Here is a general outline of steps to take:

Open "sequence.txt" Read numbers from the opened file until 3 (the a in this assignment) is found OR there is no more data in the file. If a 3 was found, then the current sequence length (so far) is 1 Read text lines until the file is depleted of data Convert each text line to a value For each value, increment the current sequence length if an epsilon value (7) is read, then read past the next number, it doesn't matter what value it is. Be sure to increment the sequence length appropriately. if the value 3 is read (an a!) then break out of this reading loop, you've found the end of the sequence! Depending on the sequence length and the last value read from the file, you can report the length of an acceptable sequence, or BOGUS. For testing purposes, create a text file with the following values (one per line): 3 10 20 30 40 3 The preceding sequence should work, and the following one should not: 1 3 4 5 6 7 8 9 8 

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

Database Design Application Development And Administration

Authors: Michael V. Mannino

4th Edition

0615231047, 978-0615231044

More Books

Students also viewed these Databases questions

Question

What is the Definition for Third Normal Form?

Answered: 1 week ago

Question

Provide two examples of a One-To-Many relationship.

Answered: 1 week ago