PYTHON REGULAR EXPRESSIONS (2A and 2B are related to each other, please answer ALL parts) 2a) ** ONLY ONE LINE EXPRESSION NEEDED(Start with ^ and end…

PYTHON REGULAR EXPRESSIONS (2A and 2B are related to each other, please answer ALL parts)

2a) **ONLY ONE LINE EXPRESSION NEEDED(Start with ^ and end with $!! define a regular expression pattern that describes a single page specification: the integers you specify here must start with a non-0 digit. Here are examples that should match/should not match a single page specification:

Match 3 and 5-8 and 12:3 and 5-8 and 6:4 and 10-20/3 and 10:10/3

NotMatch 03 and 5-08 and 3 4 and 3 to 8 and 4/3and 4-:3 and 4-6:3

MORE INFO IF NEEDED: When we print computer documents, there is a common form used to specify the page numbers to print. Generally, commas separate page specifications, where each page specification is a single page number, or a contiguous range of pages. In a page specification, a dash or a colon can separate two numbers: for a dash, these numbers specify the first and last pages in a range to print (inclusive); for a colon, they specify the first page and how many subsequent pages to print (so 10:3 means 3 pagess starting at 10: 10, 11, and 12). Finally, if either of these forms is used, we can optionally define a slash followed by a number (call it n), which means for the page specification, print every nth page in the range (so 10-20/3 means 10 through 20 , but only every 3rd page: 10, 13, 16, and 19). define a regular expression that ensures group 1 is the first page; group 2 is a dash or colon (or None if not present); group 3 is the number after the dash or colon (or None if not present); group 4 is the number after the slash (or None if not present).

2b) PYTHON 3 LANGUAGE**** Define a function named pages that takes one str as an argument, representing a list of page specifications separated by commas, and a bool value controlling whether the pages are unique: printed only once; it returns a list, sorted in ascending order, of all the pages (ints) in the page specifications. This functionmust use the regular expression pattern you wrote for part 2a and extract (using the group function) information to create the numbers in the page specification. For example, if we called the function aspages(‘5-8,10:2,3,7:10/3’,unique=True) it would return the list [3,5,6,7,8,10,11,13,16]; if we called pages(‘5-8,10:2,3,7:10/3’,unique=False) it would return the list [3,5,6,7,7,8,10,10,11,13,16].

Raise an AssertionError exception (using Python’s assert statement) if any page specifications fails to match the regular expression, or if any dash separator separates a higher first number from a lower second one: e.g., 10-8 raises/prints the exception AssertionError: pages: in page specification 10-8, 10 > 8.The page specification 8-8 is OK : it means only page 8.

example:

‘3’







Calculate Your Essay Price
(550 words)

Approximate price: $22

Calculate the price of your order

550 words
We'll send you the first draft for approval by September 11, 2018 at 10:52 AM
Total price:
$26
The price is based on these factors:
Academic level
Number of pages
Urgency
Basic features
  • Free title page and bibliography
  • Unlimited revisions
  • Plagiarism-free guarantee
  • Money-back guarantee
  • 24/7 support
On-demand options
  • Writer’s samples
  • Part-by-part delivery
  • Overnight delivery
  • Copies of used sources
  • Expert Proofreading
Paper format
  • 275 words per page
  • 12 pt Arial/Times New Roman
  • Double line spacing
  • Any citation style (APA, MLA, Chicago/Turabian, Harvard)

Our guarantees

Delivering a high-quality product at a reasonable price is not enough anymore.
That’s why we have developed 5 beneficial guarantees that will make your experience with our service enjoyable, easy, and safe.

Money-back guarantee

You have to be 100% sure of the quality of your product to give a money-back guarantee. This describes us perfectly. Make sure that this guarantee is totally transparent.

Read more

Zero-plagiarism guarantee

Each paper is composed from scratch, according to your instructions. It is then checked by our plagiarism-detection software. There is no gap where plagiarism could squeeze in.

Read more

Free-revision policy

Thanks to our free revisions, there is no way for you to be unsatisfied. We will work on your paper until you are completely happy with the result.

Read more

Privacy policy

Your email is safe, as we store it according to international data protection rules. Your bank details are secure, as we use only reliable payment systems.

Read more

Fair-cooperation guarantee

By sending us your money, you buy the service we provide. Check out our terms and conditions if you prefer business talks to be laid out in official language.

Read more

Order your essay today and save 10% with the coupon code: best10