Calfinder.py


import gc
gc.disable()

#Written by Acheev Bhagat
#Calorie Finder
import math

caldef = {}
results = {}

class calories:
	@staticmethod
	def adddef(a, b):
		b = float(b)
		caldef[a] = b
	class calculate:
		@staticmethod
		def search(key):
			if key in caldef == True:
				return "It's there."
			elif key in caldef == False:
				return "It's not there."
			else:
				return "A problem may have ocurred."
		@staticmethod
		def li():
			for i in caldef:
				print i
		@staticmethod
		def delitem(ite):
			del caldef[ite]
		@staticmethod
		def choose(a1, a2):
			a3 = caldef[a1]
			a2 = int(a2)
			a3 = int(a3)
			a4 = a2 * a3
			a5 = [a2, a3]
			results[a5] = a4
		@staticmethod
		def history():
			for keys, values in results.items():
				print keys, results
while 1:
	print "Check out your food's calories!\n"
	ty = raw_input("Try it out(type 'help' for more options): ")
	print "\n"
	if ty == "help":
		print "Here is a list of options: \n"
		print "add - adds food and amount of calories per pound to memory.\n" 
		print "choose - chooses a food and measures how many calories were taken in per pound.\n"
		print "delete - deletes an item from memory.\n"
		print "end - ends program.\n"
		print "history - gives history of calculations and measurements.\n"
		print "list - gives list of all foods in memory.\n"
		print "search - searches if particular food is in memory.\n"
	elif ty == "add":
		a = raw_input("What's the food? ")
		b = float(input("How many calories are in it? "))
		calories.adddef(a, b)
		print "Definition added.\n" 
	elif ty == "end":
		print "Program is ending...\n"
		print "Deleting code\n"
		del(calories)
		print "Deleting definitions\n"
		del(caldef)
		print "Deleting history\n"
		del(results)
		break
print "Program has ended"

This evolved out of the Pear Calorie Converter. I wrote it mainly for practice.