53.4k views
3 votes
Label the strength of a beer based on its ABV. For each beer display the beer's name, ABV, and a textual label describing the strength of the beer. The label should be "Very High" for an ABV more than 10, "High" for an ABV of 6 to 10, "Average" for an ABV of 3 to 6, and "Low" for an ABV less than 3. Show the records by beer name.

User Radix
by
4.2k points

1 Answer

6 votes

Answer:

By presuming the question expect us to write a program to address the problem and the solution code written in Python is as follow:

  1. beer_name = input("Enter beer name: ")
  2. abv = int(input("Enter ABV value: "))
  3. if(abv > 10):
  4. label = "Very High"
  5. elif(abv >=6):
  6. label = "High"
  7. elif(abv >=3):
  8. label = "Average"
  9. else:
  10. label = "Low"
  11. print("Beer Name: " + beer_name)
  12. print("ABV value: " + str(abv))
  13. print(label)

Step-by-step explanation:

Firstly, we can use input function to prompt user to input beer name and ABV value (Line 1 - 2).

Next, create if else if statements to check abv fallen into which range of value and then set a label accordingly (Line 4 -11). For example if abv is 4, the label will be set to "Average".

At last, print the information of beer that includes beer name, abv value and label (Line 13 - 15).

User Frabiacca
by
4.1k points