Question: 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.

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

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

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 Accounting Questions!