Calorie Management system
Calorie Management system
Kanyakumari
Affiliated to CBSE
2021 - 2022
Submitted to :
Submitted by :
Class :
Registration No :
2021 - 2022
CERTIFICATE
i Principal
We extend our hearty thanks to our teacher Mrs.Rajitha R V for her valuable
With great enthusiasm we express our thanks to our parents and family members
ii
1 Certificate i
2 Acknowledgment ii
3 Overview of programming 5 - 14
language
4 Hardware and the software 15
requirements
5 Modules 16 - 17
6 Flow diagram 18
7 Source code 19 - 24
8 Screenshots 25 - 27
9 Bibliography 28
Python
semantics. Its high-level built in data structures, combined with dynamic typing and dynamic
binding, make it very attractive for Rapid Application Development, as well as for use as a
scripting or glue language to connect existing components together. Python's simple, easy to
learn syntax emphasizes readability and therefore reduces the cost of program maintenance.
Python supports modules and packages, which encourages program modularity and code
reuse. The Python interpreter and the extensive standard library are available in source or
binary form without charge for all major platforms, and can be freely distributed.
Python has a large community of developer who are actively using python for software
development. Python is also being used in the fields of machine learning, neural networks
Python is an open source software, and it gets frequently updated which makes it bug free
Windows
2. Underneath the heading at the top that says Python Releases for windows, click on
3. Scroll to the bottom and select either Windows x84-64 executable installer for 64-
For Windows, you can choose either the 32-bit or 64-bit installer. Here’s what the difference
If your system has a 32-bit processor, then you should choose the 32-
bit installer
purposes. The 32-bit version will generally use less memory, but the
computation.
Once you have chosen and downloaded an installer, simply run it by double-clicking on the
downloaded file. A dialog should appear that looks something like this:
The application of the python is a result of the combination of features which give this
language an edge over others. Some of the benefits of programming in python include:
that make python capable of interacting with most of the other languages and
platforms.
Python provides it’s users with large library which includes areas like machine
interfaces. Many of the programming tasks have already been scripted into the
library and can be used in just a couple of lines. This increases the workflow
Python is an open-source language means anyone can look into its source code
and make changes to it. This means many people are working with python and
simple syntax. This makes it an perfect language for the beginners and also it
modules to access, modify and use them to their fullest. Python also provide
the option of dynamic high level data typing which reduces the length of the
and its own unit testing framework, all of which contribute to the increase in
its speed and productivity. Python is considered a viable option for building
Python also has a robust standard library, which enables web programmer to
String operation etc. without writing additional code. They can use specific
Many studies have proved that Python is slower than other modern programming languages
like Java and C++. So the developers have to frequently explore ways to enhance the Python
application’s speed. However, they have a number of options to make the applications written
in Python run faster. For instance, the developers can create a custom runtime, and use it
instead of the default runtime of the programming language. Likewise, they can rewrite the
Beginners often find it pick and learn the right version of Python. Officially, Python 2.x is
described as legacy, whereas Python 3.x is described as current and futuristic. But both
versions of the programming language have been updated on a regular basis. Also, a large
percentage of programmers still prefer Python 2 to Python 3. There are also a number of
3) Application Portability
Python code into code understandable by the operating system. They need to install specific
version of Python interpreter on the operating system to run the Python application on that
platform. The shortcoming does not allow programmers to use Python for developing cross-
platform applications. Also, they could not port the application from one platform to another
smoothly.
1
Amrita vidyalayam, kanyakumari
0
4) Requires Additional Testing
define the type of a variable while declaring it. The feature makes it easier for programmers
to write code freely. But a number of critical bugs or defects emerge at the time of
compilation as the variable types are not defined explicitly. So the developers must perform a
number of tests additionally to identify and fix the bugs during runtime.
Many programmers prefer using Python as a scripting language to build web applications
rapidly. But Python does not come with built-in web development capabilities. Also, the
standard implementation of Python does not boost the web applications’ performance across
multiple browsers. That is why, the Python developers have to use a number of Python web
option to choose from several full-stack web frameworks for Python including Django,
The steady decline in mobile web usage has made it essential for modern businesses to
launch mobile apps. Often developers have to write mobile apps in a particular programming
language according to the targeted mobile platform. For instance, they need to write iOS app
in either Objective-C or Swift. Likewise, mobile apps for Android need to be written in Java.
But the developers cannot use Python directly for developing mobile apps by targeting any
popular mobile platforms. They have to use frameworks like Kivy to build cross-platform
1
Amrita vidyalayam, kanyakumari
1
7) Depends on Third-Party Frameworks and Libraries
Python lacks a number of features provided by other modern programming languages. So the
programmers have to use a number of third-party frameworks and tools to build web
applications and mobile apps in Python. However, they need to use open source frameworks
and libraries to avoid increasing project overheads. The cost factor restricts the developers
from availing the advanced features and functionality provided by commercial frameworks.
Nowadays, developers are required to make the application code readable and maintainable.
While writing code, programmers frequently deactivate a specific section or block of code by
using block comments. Unlike other modern programming languages, Python does not
support block comments. Hence, the programmers have to assess the quality of the code
either by writing comments for each line of code or removing a specific section of code at the
time of execution. The lack of block comments support requires programmers to put
additional effort.
Python is supported by a large and active community. The members of the Python
community regularly share new packages or modules to make it easier for programmers to
add functionality to the application. But developers often complain that the quality of
individual Python modules or packages differs. Some of these packages lack adequate
support, and are not updated regularly. Hence, the programmers have to do some initial
1
Amrita vidyalayam, kanyakumari
2
Many developers prefer using Python for developing custom statistical and big data
applications.
But developers need to use additional statistical and data analysis packages to write statistical
applications more efficiently. Also, they have to use specific libraries like Pygal, Seaborn and
Bokeh to accomplish data visualization. They cannot make the Python application present
and analyze huge volumes of data without using these libraries and tools.
On the whole, the developers can use Python to build a variety of software applications
rapidly. But they have to use a number of third-party libraries and frameworks additionally to
overcome the limitations of this high-level programming language. At the same time, they
also need to explore ways to enhance the performance and speed of the Python applications
consistently.
Python was designed for readability, and has some similarities to the
languages often use curly-brackets for this purpose. time and effort to
1
Amrita vidyalayam, kanyakumari
3
Applications of python programming language:
Machine learning
Deep learning
Neural network
Operation system
Web services
Language development
Prototyping
1
Amrita vidyalayam, kanyakumari
4
Hardware and the software requiremnts
Hardware requirement:
PENTIUM processor
2 GB of RAM
1 GB HD
Mouse
Keyboard
VGA/HDMI
Software requirements:
Windows 7
Python IDLE
1
Amrita vidyalayam, kanyakumari
5
Modules
1. MENU
This displays the menu of options that are provided in the project
The details about the food taken at the particular part of the day as food name,
The details about the food taken at a particular day can be viewed by the
“View Data” option in the menu and by entering the date , month and year.
4. Viewing the data for a particular month and the trend of weight loss or gain for
a month
The details about the food taken in a particular month day can be viewed with
the help of the option “view data for a whole month and the trend of weight”.
With this option the trend of the weight loss or the weight gain can be
predicted roughly.
1
Amrita vidyalayam, kanyakumari
6
5. View the average calories burned in a particular month
The average calories burned on a particular month can be seen with the help of
The path needed to store the data is entered through this option “o”.
7. Exit
1
Amrita vidyalayam, kanyakumari
7
FLOW DIAGRAM
1
Amrita vidyalayam, kanyakumari
8
SOURCE CODE
import csv
from datetime import date
from datetime import datetime
import os
import os.path
import shutil
'''
here in this part of the code , we are getting the details about the food storing them
inout taken and stored in as a list and gonna be stored in csv
'''
def app_input():
1
Amrita vidyalayam, kanyakumari
9
path_storage_year = path_storage+ str(todays_date.year)
path_storage_month = path_storage_year + '/' + str(todays_date.month)
path_storage_day = path_storage_month + '/' + str(todays_date.day)
path_storage_time = path_storage_day + '/' + part_of_day
path_calorie_storage = path_boss[0][0] + "/Calories"
path_calorie_storage_month = path_calorie_storage + "/" + str(todays_date.month)
if not os.path.exists(path_storage):
os.mkdir(path_storage)
if not os.path.exists(path_storage_year):
os.mkdir(path_storage_year)
if not os.path.exists(path_storage_month):
os.mkdir(path_storage_month)
if not os.path.exists(path_storage_day):
os.mkdir(path_storage_day)
if not os.path.exists(path_calorie_storage):
os.mkdir(path_calorie_storage)
if not os.path.exists(path_calorie_storage_month):
os.mkdir(path_calorie_storage_month)
if no_of_food > 0:
for x in range(1, no_of_food + 1):
name_of_food = input("food taken name: ")
amount_of_food = int(input("enter the amount of food taken(number/grams)"))
food_lst.append([int(x), part_of_day, now.strftime("%H"), name_of_food, amount_of_food])
no_of_food -= 1
2
Amrita vidyalayam, kanyakumari
0
if no_of_food_ml > 0:
for x in range(1, no_of_food_ml + 1):
ml_list.append([part_of_day, now.strftime("%H"), name_of_food, amount_of_food])
no_of_food_ml -= 1
with open(file, 'w') as csvfile:
csv_writer = csv.writer(csvfile)
csv_writer.writerows(ml_list)
shutil.move(path_boss[0][0] + "/" + str(file), path_storage_ml)
def god_input():
god_path = []
god_copy_path = input('''enter the path :
example: C:/Users/chida/PycharmProjects/pythonProject ''')
god_path.append(god_copy_path)
print(god_path)
return god_copy_path
def app_output():
calorie = {'idli': 39, 'idli-podi': 34, 'chutney': 51, 'Dosa': 133, 'rice': 130, 'rasam': 59}
year = input("Enter the year of the data to be read")
month = input("Enter the month of the data to be read")
date = input("Enter the date of the data to be read")
timing = ["morning", "afternoon", "night", "evening", "brunch", "snack"]
part_path = year + '/' + month + '/' + date
part_name = year + '-' + month + '-' + date
data = []
finale_data = []
ding_dong = []
path_boss = []
with open("godfather_path", 'r') as file:
2
Amrita vidyalayam, kanyakumari
1
target = csv.reader(file)
for lines in target:
path_boss.append(lines)
print(path_boss)
path = path_boss[0][0] + "/Data-DON'T-DELETE/" + part_path + "/" + part_name
filename = part_name + ''
for i in timing:
path1 = path + i
if os.path.exists(path + i):
with open(os.path.join(path1)) as file:
target = csv.reader(file)
for lines in target:
data.append(list(lines))
for i in range(1, data.count([]) + 1):
del data[i]
del data[0]
for i in range(0, len(data)):
if ['S.number', 'part-of-day', 'food_time', 'name', 'amount_of_food'] in data:
data.remove(['S.number', 'part-of-day', 'food_time', 'name', 'amount_of_food'])
sum_calorie = 0
for i in range(0, len(data)):
sum_calorie += calorie[data[i][3]]*int(float(data[i][4]))
avg_calorie = sum_calorie
print(avg_calorie)
if avg_calorie > 2500:
print("Watch your calorie intake! Exercise tomorrow!!")
def calorie_counter():
year = input("Enter the year of the data to be read")
month = input("Enter the month of the data to be read")
path_boss = []
data = []
finalcal = []
final_calorie = 0
with open("godfather_path", 'r')as file:
target = csv.reader(file)
for lines in target:
path_boss.append(lines)
for x in range(1, 32):
y = os.path.exists(path_boss[0][0] + "/Calories/" + month)
if y:
filepath = path_boss[0][0] + "/Calories/" + month + '/' + str(x) + " " + str(year)
z = os.path.exists(filepath)
if os.path.exists(filepath):
with open(os.path.join(filepath)) as file:
target = csv.reader(file)
2
Amrita vidyalayam, kanyakumari
2
for lines in target:
data.append(lines)
def app_output_for_full_month():
calorie = {'idli': 39, 'idli-podi': 34, 'chutney': 51, 'Dosa': 133, 'rice': 130, 'rasam': 59}
year = input("Enter the year of the data to be read")
month = input("Enter the month of the data to be read")
part_path = year + '/' + month
# part_name = year + '-' + month
data = []
timing = ["morning", "afternoon", "night", "evening", "brunch", "snack"]
path_boss = []
with open("godfather_path", 'r') as file:
target = csv.reader(file)
for lines in target:
path_boss.append(lines)
print(path_boss)
path = path_boss[0][0] + "/Data-DON'T-DELETE/" + part_path + "/"
for i in range(1, 31):
x = os.path.exists(path + str(i))
if x:
for k in timing:
filepath = path + str(i) + '/' + year + '-' + month + '-' + str(i) + k
if os.path.exists(filepath):
with open(os.path.join(filepath)) as file:
target = csv.reader(file)
for lines in target:
data.append(list(lines))
# counting
count_items = []
count = []
item_count = []
for i in range(0, len(data)):
count_items.append(data[i][3])
y=0
2
Amrita vidyalayam, kanyakumari
3
for i in range(0, len(count_items)):
y=x
if count_items[i] != x:
count.append(count_items[i])
x = count_items[i]
for i in count:
x = count_items.count(i)
item_count.append(x)
while True:
todays_date = date.today()
print('''
Enter the corresponding input for the action to be taken:
1) Input Data for the day
2) view Data for a day
3) view Data for a whole month
4) view the trend of weight
5) Exit
when using this app for the first time enter "0"
to enter the path where this program is located.
I don't know how to include it in the code!
sorry for the inconvenience caused !
Thank you for using our app!!''')
2
Amrita vidyalayam, kanyakumari
4
elif
elif
else:
2
Amrita vidyalayam, kanyakumari
5
2
Amrita vidyalayam, kanyakumari
6
2
Amrita vidyalayam, kanyakumari
7
2
Amrita vidyalayam, kanyakumari
8
2
Amrita vidyalayam, kanyakumari
9
BIBLIOGRAPHY:
1.python.org
3
Amrita vidyalayam, kanyakumari
0