Vegan Calculator using Python

A vegan diet consists only of plant-based foods. It does not contain any animal products like meat, eggs, milk, honey, etc. A vegan lifestyle extrapolates this into not using day-to-day articles made up of animal products like leather, wool, silk, etc. A person observing this type of lifestyle is called a vegan.

Veganism has many health benefits. It also has multiple environmental benefits. According to multiple researches, a vegan person in a single month can save :

  • 1100 gallons or 4164 litres of water
  • 45 pounds or 20.4 kgs of grain
  • 30 square feet or 2.7 square metre of forest
  • 20 pounds or 9 kgs of carbon dioxide

Algorithm :

  1. Convert the years into months and add it to the months.
  2. Calculate the amount of items saved according the values mentioned above.
  3. Use round() method to round off the values, and then print them.
filter_none

edit
close

play_arrow

link
brightness_4
code

# function to calculate the amount of
# things saved by being vegan
def vegan_calculator(m, y):
  
    # coverting years to months
    months_vegan = y * 12 + m
  
    # calculating things saved
    water = 4164 * months_vegan
    grain = 20.4 * months_vegan
    forest = 2.7 * months_vegan
    co2 = 9 * months_vegan
  
    # printing the statistics
    print("You have been vegan for " + str(months_vegan) + " months.")
    print("\nYou have successfully saved :")
    print(str(water) + " litres of water")
    print(str(round(grain)) + " kgs of grain")
    print(str(round(forest)) + " square metres of forest")
    print(str(round(co2)) + " kgs of carbon dioxide")
  
# Driver code
if __name__=="__main__":
    months = 4
    years = 2
    vegan_calculator(months, years)

chevron_right


Output :

You have been vegan for 28 months.

You have successfully saved :
116592 litres of water
571 kgs of grain
76 square metres of forest
252 kgs of carbon dioxide
My Personal Notes arrow_drop_up

Check out this Author's contributed articles.

If you like GeeksforGeeks and would like to contribute, you can also write an article using contribute.geeksforgeeks.org or mail your article to contribute@geeksforgeeks.org. See your article appearing on the GeeksforGeeks main page and help other Geeks.

Please Improve this article if you find anything incorrect by clicking on the "Improve Article" button below.


Article Tags :

Be the First to upvote.


Please write to us at contribute@geeksforgeeks.org to report any issue with the above content.