• Anirudh Gupta

Environmental True Cost Calculator

This was made for and submitted as the Final Project for my amazingggg 6-week Stanford CS106 Code-in-Place Class!



The program is super simplistic and rudimentary, but may turn out to be a work in progress since I think a lot of cool impactful stuff can be done with it in the Future. Here's the code:


'''
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
ENVIRONMENTAL TRUE COST CALCULATOR
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
2020 onward, I believe consumers will start getting more conscious about what they buy and consume.
They will gradually shift from conspicuous consumption to conscious consumption.
One main way this will happen is that companies themselves will choose to, or will have to,
label the true cost of production of their products.

True Cost = $ Price + Litres of Water + Kg. of Carbon (GHG) Emissions

Every Product should be and hopefully will be labeled with it's True Environmental + Economic  Cost
'''

# All Constants for food / gm or ml : Data Source - https://ourworldindata.org/environmental-impacts-of-food

PRICE_OF_NUTS = 35/1000
GHG_OF_NUTS = 2.6/1000
WF_OF_NUTS = 4134/1000

PRICE_OF_EGGS = 58/1000
GHG_OF_EGGS = 42/1000
WF_OF_EGGS = 578/1000

PRICE_OF_MILK = 1.5/1000
GHG_OF_MILK = 95/1000
WF_OF_MILK = 628/1000

PRICE_OF_CHEESE = 16/1000
GHG_OF_CHEESE = 108/1000
WF_OF_CHEESE = 5605/1000

PRICE_OF_FISH = 15/1000
GHG_OF_FISH = 60/1000
WF_OF_FISH = 3691/1000

PRICE_OF_BEEF = 15/1000
GHG_OF_BEEF = 500/1000
WF_OF_BEEF = 1451/1000
# ~~~~~~~~~~~~~~~

from simpleimage import SimpleImage

def main():
    welcome_message()
    product_list()
    state_true_costs()
    state_sustainability_request()
    build_cart()

def welcome_message():
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print('Welcome to the Stanford Code-in-Place Grocery Store :)')
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print('Please browse around!')
    print('Just remember to shop with the Environment in mind for your Weekly supplies')

def product_list():
    num1 = input("Enter?")
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print('Today we have: ' + ' NUTS, ' + ' EGGS, ' + ' MILK, ' + ' CHEESE, ' + ' FISH and ' + ' BEEF ')

def state_true_costs():
    num2 = input("View True Cost List for Each Item? (per gram or ml)")
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print(' NUTS / gm : ' + '$' + str(PRICE_OF_NUTS) + ' + ' + str(GHG_OF_NUTS) + ' Kg of Carbon' + ' + ' + str(WF_OF_NUTS) + ' Litres of Water')
    print(' EGGS / gm : ' + '$' + str(PRICE_OF_EGGS) + ' + ' + str(GHG_OF_EGGS) + ' Kg of Carbon' + ' + ' + str(WF_OF_EGGS) + ' Litres of Water')
    print(' MILK / ml : ' + '$' + str(PRICE_OF_MILK) + ' + ' + str(GHG_OF_MILK) + ' Kg of Carbon' + ' + ' + str(WF_OF_MILK) + ' Litres of Water')
    print(' FISH / gm : ' + '$' + str(PRICE_OF_FISH) + ' + ' + str(GHG_OF_FISH) + ' Kg of Carbon' + ' + ' + str(WF_OF_FISH) + ' Litres of Water')
    print(' BEEF / gm : ' + '$' + str(PRICE_OF_BEEF) + ' + ' + str(GHG_OF_BEEF) + ' Kg of Carbon' + ' + ' + str(WF_OF_BEEF) + ' Litres of Water')
    print(' CHEESE / gm : ' + '$' + str(PRICE_OF_CHEESE) + ' + ' + str(GHG_OF_CHEESE) + ' Kg of Carbon' + ' + ' + str(WF_OF_CHEESE) + ' Litres of Water')
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')

def state_sustainability_request():
    num3 = input("Incoming Message from THE SUSTAINABILITY MAFIA!!!!!........ View?")
    print("For our Earth's sake, please keep the Environmental Impact of your weekly grocery shopping BELOW 1000 Kg of Carbon AND 5000 Litres of Water")
    num4 = input("Buy Now?")

def build_cart():
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    numnuts = input("Grams. of Nuts You'd Like : ")
    numeggs = input("Grams. of Eggs You'd Like : ")
    nummilk = input("Ml. of Milk You'd Like : ")
    numfish = input("Grams. of Fish You'd Like : ")
    numbeef = input("Grams. of Beef You'd Like : ")
    numcheese = input("Grams. of Cheese You'd Like : ")

    #checkout message
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print("YOU'RE BUYING : " + str(numnuts) + " gms. of Nuts, " + str(numeggs) + " gms. of Eggs, " + str(nummilk) + " ml. of Milk, " + str(numfish) + " gms. of Fish, " + str(numbeef) + " gms. of Beef and " + str(numcheese) + " gms. of Cheese.")
    input("Check-Out?")

    economic_cost = int((float(numnuts) * PRICE_OF_NUTS) + (float(numeggs) * PRICE_OF_EGGS) + (float(numcheese) * PRICE_OF_CHEESE) + (float(numbeef) * PRICE_OF_BEEF) + (float(numfish) * PRICE_OF_FISH) + (float(nummilk) * PRICE_OF_MILK))
    carbon_cost = ((float(numnuts) * GHG_OF_NUTS) + (float(numeggs) * GHG_OF_EGGS) + (float(numcheese) * GHG_OF_CHEESE) + (float(numbeef) * GHG_OF_BEEF) + (float(numfish) * GHG_OF_FISH) + (float(nummilk) * GHG_OF_MILK))
    water_cost = ((float(numnuts) * WF_OF_NUTS) + (float(numeggs) * WF_OF_EGGS) + (float(numcheese) * WF_OF_CHEESE) + (float(numbeef) * WF_OF_BEEF) + (float(numfish) * WF_OF_FISH) + (float(nummilk) * WF_OF_MILK))

    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')
    print(' YOUR ECONOMIC COST = ' + '$' + str(economic_cost))
    print(' YOUR ENVIRONMENTAL COST = ' + str(carbon_cost) + ' Kg. of Carbon and ' + str(water_cost) + ' Ltrs. of Water.')
    print('~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~')

    # based on the customer's choices, show the relevant image
    if carbon_cost < 1000 and water_cost < 5000:
        happy = SimpleImage('images/happy.png')
        happy.show()
    else:
        sad = SimpleImage('images/sad.png')
        sad.show()



if __name__ == '__main__':
    main()

76 views
  • Ani FB
  • Quora
  • Ani LinkedIn
  • Ani Insta
  • Ani Twitter
  • Ani SoundCloud
Email Ani
Email Ani
Email Ani