n do this ( i only need the code, no need for explanation):   5. View user meals and generate health information When the user chooses 5, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is not passed to the function (i.e., the user did not chose option 1 before choosing option 4), call the function that allows the user to either load or create a user profile (option 1 from the main menu). Otherwise, perform the following tasks: • First, check the file username-recipes.txt exists, if the file does not exist, ask the user to generate recipes to view their health information, and call the function that allows the user to do so (i.e., call the function that shows choice 2 from the main menu). • If the file username-recipes.txt exists, open

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

with python do this ( i only need the code, no need for explanation):

 

5. View user meals and generate health information
When the user chooses 5, the first thing that it should do is to check whether the user information is loaded in the program (i.e., check if the user information is passed to the function that generates recipe recommendations). If the user information is not passed to the function (i.e., the user did not chose option 1 before choosing option 4), call the function that allows the user to either load or create a user profile (option 1 from the main menu). Otherwise, perform the following tasks:
• First, check the file username-recipes.txt exists, if the file does not exist, ask the user to generate recipes to view their health information, and call the function that allows the user to do so (i.e., call the function that shows choice 2 from the main menu).
• If the file username-recipes.txt exists, open it in read mode and retrieve (i.e., read) all the information that is stored in this file.
• Ask the user to enter the number of servings per meal that they would like to perform the health analysis for (integer value).
• Write a function that opens the file recipes.csv in read mode and uses the randomly generated recipe names of the user to search for their details from the file recipes.csv. The function should return the details of all the randomly generated recipes by the user.
• Pass the information of each recipe to a function that prints all the recipe details like step 3 from (a).
• Since the user provided the number of servings per recipe, the calories per meal retrieved from the file recipes.csv should be updated as follows: meal calories = meal calories x serving size.
• For each printed meal, check if the calories per serving size cause a caloric surplus or caloric deficit. A caloric surplus happens when the calories per serving for a meal is greater than TEE of the user when divided on the number of meals in a session. Print this status for every meal in the generated report.
• Add all the new values of calories to a list for later usage.
8
• After printing the details of every recipe that the user generated from every session, show the total and average number of calories per session; such information can be found in the file username-recipes.txt. Remember to update the values by multiplying them with the serving size that the user provides.
• Check if the user experienced an overall trend of calorie surplus or calorie deficit based on the meals that they generated. To do this, check the following condition:
o Compare the total calories for all the meals per session (i.e., the sum of the calories in the list of meal calories) with the user’s TEE. If the total calories are more than TEE, then the user is experiencing a calorie surplus.
o Otherwise, the user is experiencing a calorie deficit.
• Print the overall trend of the caloric status of the user (surplus or deficit) in each session.
• Use matplotlib to plot the list that contains the calories of each recipe from all the sessions using a pie chart plot.

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY