Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Task one: (1 mark) Design a function to check whether a document with the format CPF, the input for the function is a file path.

image text in transcribedimage text in transcribed

Task one: (1 mark) Design a function to check whether a document with the format CPF, the input for the function is a file path. The output is a Boolean variable. If the file has the specified format, return True. Else, return False. Specifically, there are three criterions your function should check, 1) if the text has title, author, and body 2) if each part is separated by two blank lines 3) each paragraph in the file body is separated by one blank line. If any one of the criterions is violated, your function should return False. Any blank part is regarded as violating the first rule, e.g., an empty body means that the file body part is missing. Write the code for this function in a file named task1.py. The format CPF: CPF is a custom document format. Each document contains three parts: Title, Author, and Body. Each part is separated by two blank lines. In the document Body, each paragraph is separated by one blank line. Document example is attached. Example: How to learn python? Nick Referencing the official tutorial is a good way to learn. You don't need to memorize the usage of all APIs, just remember the most commonly used APIs. Try writing some programs yourself. With practice, you'll develop your own programming style, know how to solve common problems, and how to seek professional help. Another good way to learn is to read other people's code (such as the code on github) and learn how others solve problems. Task one: (1 mark) Design a function to check whether a document with the format CPF, the input for the function is a file path. The output is a Boolean variable. If the file has the specified format, return True. Else, return False. Specifically, there are three criterions your function should check, 1) if the text has title, author, and body 2) if each part is separated by two blank lines 3) each paragraph in the file body is separated by one blank line. If any one of the criterions is violated, your function should return False. Any blank part is regarded as violating the first rule, e.g., an empty body means that the file body part is missing. Write the code for this function in a file named task1.py. The format CPF: CPF is a custom document format. Each document contains three parts: Title, Author, and Body. Each part is separated by two blank lines. In the document Body, each paragraph is separated by one blank line. Document example is attached. Example: How to learn python? Nick Referencing the official tutorial is a good way to learn. You don't need to memorize the usage of all APIs, just remember the most commonly used APIs. Try writing some programs yourself. With practice, you'll develop your own programming style, know how to solve common problems, and how to seek professional help. Another good way to learn is to read other people's code (such as the code on github) and learn how others solve problems

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_2

Step: 3

blur-text-image_3

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

IT Audit Control And Security

Authors: Robert R. Moeller

1st Edition

0471406767, 9780471406761

More Books

Students also viewed these Accounting questions

Question

What was the Sec. 7520 rate for May, June, and July 2014?

Answered: 1 week ago

Question

ASAP ANSWER PLEASE!!!...

Answered: 1 week ago