Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

The file below this drop, wine.txt, contains the records from a wine data file.

ID: 3599217 • Letter: T

Question

The file below this drop, wine.txt, contains the records from a wine data file. The 5 fields in each row are: The wine identification number ·Wine name · Type of wine (2-Sparkling, 3-Fortified, 4-Sweet, 5-White, 6-Red) Year wine was made · Winery Number This assignment requires that you create a report that will print the number of wines by type. The report should have a proper heading that includes a main heading e The main heading should include the current date The report heading should also have column headings for the type of wine and total (for the total of each type of wine) The record output should be formatted to display the data (wine type and count) below each column header The report should print on a "clean screen"

Explanation / Answer

file = open("wine.txt","r")

while(1):
   print("1.Display wines as per types (2=Sparkling,3=Fortified,4=sweet,5=White,6=red")
   print("2.Display all wines")
   print("3.Quit")

  
   ch = int(input("Enter your choice:"))
   if ch==3:
      break
   if ch == 1:
      type = int(input("Enter type:"))
      for line in file:
          list = line.split(':')
          if int(list[2]) == type:
            
             print(line)
   if ch == 2:
     
      for line in file:
            print(line)

file.close()

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote