8.7 LAB: Parsing food data Given a text file containing the availability of food items, write a program that reads the information from the text file and outputs the available food items. The program first reads the name of the text file from the user. The program then reads the text file, stores the information into four separate lists, and outputs the available food items in the following format: name (category) - description Assume the text file contains the category, name, description, and availability of at least one food item, separated by a tab character ("\t"). Ex: If the input of the program is: food.txt and the contents of food.txt are: Sandwiches Sandwiches Sandwiches Ham sandwich Classic ham sandwich. Available Chicken salad sandwich Chicken salad sandwich Not available Not available. Cheeseburger Classic cheeseburger Salads Caesar salad Chunks of romaine heart lettuce dressed with lemon juice Available Salads Asian salad Mixed greens with ginger dressing, sprinkled with sesame Not available. Available Water 16oz bottled water Coca-Cola 16oz Coca-Cola Not available. Chicken tacos Grilled chicken breast in freshly made tortillas Not available Beef tacos Ground beef in freshly made tortillas Available Avocado sandwich. Sliced avocado with fruity spread Not available. Beverages Beverages Mexican food Mexican food Vegetarian the output of the program is: Ham sandwich (Sandwiches) -- Classic ham sandwich. Caesar salad (Salads) -- Chunks of romaine heart lettuce dressed with lemon juice Water (Beverages) -- 16oz bottled water Beef tacos (Mexican food) - Ground beef in freshly made tortillas
Control structures
Control structures are block of statements that analyze the value of variables and determine the flow of execution based on those values. When a program is running, the CPU executes the code line by line. After sometime, the program reaches the point where it has to make a decision on whether it has to go to another part of the code or repeat execution of certain part of the code. These results affect the flow of the program's code and these are called control structures.
Switch Statement
The switch statement is a key feature that is used by the programmers a lot in the world of programming and coding, as well as in information technology in general. The switch statement is a selection control mechanism that allows the variable value to change the order of the individual statements in the software execution via search.
8.7 Lab Parsing food data
in python please
Trending now
This is a popular solution!
Step by step
Solved in 3 steps