0% found this document useful (0 votes)
4 views

Calorie Management system

The document outlines a Computer Science project submitted by students at Amrita Vidyalayam, Kanyakumari, for the academic year 2021-2022. It includes sections on Python programming language, its advantages and limitations, hardware and software requirements, and a project overview with modules and source code. The project emphasizes the use of Python for various applications and provides a flow diagram and acknowledgment of support from school authorities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views

Calorie Management system

The document outlines a Computer Science project submitted by students at Amrita Vidyalayam, Kanyakumari, for the academic year 2021-2022. It includes sections on Python programming language, its advantages and limitations, hardware and software requirements, and a project overview with modules and source code. The project emphasizes the use of Python for various applications and provides a flow diagram and acknowledgment of support from school authorities.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 30

Amritapuram, Saravanantheri,

Kanyakumari

Affiliated to CBSE

2021 - 2022

COMPUTER SCIENCE PROJECT


TOPIC :

Submitted to :

Submitted by :

Class :

Registration No :

In partial fulfilment of the requirement of the


CENTRAL BOARD OF SECONDARY EDUCATION CERTIFICATE EXAMINATION

Amrita vidyalayam, kanyakumari 1


Amritapuram, Saravanantheri,
Kanyakumari
Affiliated to CBSE

2021 - 2022

CERTIFICATE

This is to certify that ____________________________, _____________________,

__________________________ of class XI Section ________ Reg no_________________,

_______________ , _________________ has completed his/ her project in the subject

______________________________ as required according to the Central Board of

Secondary Education for the academic session 2021 - 2022

Date: Teacher in-charge

i Principal

Amrita vidyalayam, kanyakumari 2


ACKNOWLEDGEMENT

First and foremost we thank Lord Almighty for showering blessings on us to

complete this project in due time.

Our sincere thanks towards our school management “Amrita Vidyalayam ,

Kanyakumari” for giving an environment for us to learn.

We express our gratitude and delightfulness to our respected Principal, Mr.Pradeesh

Kumar M for his kind cooperation in all aspects.

We extend our hearty thanks to our teacher Mrs.Rajitha R V for her valuable

suggestions and encouragement for the successful completion of the project.

With great enthusiasm we express our thanks to our parents and family members

for their support.

ii

Amrita vidyalayam, kanyakumari 3


Table of Contents

S.No Contents Page No.

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

Amrita vidyalayam, kanyakumari 4


Overview of the programming language

Python

Python is an interpreted, object-oriented, high-level programming language with dynamic

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

and much more!

Python is an open source software, and it gets frequently updated which makes it bug free

and largely compatible with different types of devices and platforms.

Python is a wonderful language and you can too start to learn!

Amrita vidyalayam, kanyakumari 5


How to download and install python:

Windows

Step 1: Download the python 3 Installer

1. Go to the download page at python.org

2. Underneath the heading at the top that says Python Releases for windows, click on

the link for the Latest Python 3 Release – Python 3.x.x

3. Scroll to the bottom and select either Windows x84-64 executable installer for 64-

bit or Windows x86 executable installer for 32-bit

For Windows, you can choose either the 32-bit or 64-bit installer. Here’s what the difference

between the two comes down to:

 If your system has a 32-bit processor, then you should choose the 32-

bit installer

 On a 64-bit system, either installer will actually work for most

purposes. The 32-bit version will generally use less memory, but the

64-bit version performs better for applications with intensive

computation.

 If you’re unsure which version to pick, go with the 64-bit version.

Step 2: Run the Installer

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:

Amrita vidyalayam, kanyakumari 6


Then just click Install Now.

Amrita vidyalayam, kanyakumari 7


Advantages of Python Programming language

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:

1. Presence of third party modules:

The Python Package Index (PyPI) contains numerous third-party modules

that make python capable of interacting with most of the other languages and

platforms.

2. Extensive network of libraries:

Python provides it’s users with large library which includes areas like machine

learning, internet protocols, neural network, web services, operating system

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

and also allows us the concentrate on the project more efficiently.

3. Open source and community development:

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

also for python making the language almost bug-less.

4. Learning ease and support available:

Python is an excellent language which offers readability and also uncluttered

simple syntax. This makes it an perfect language for the beginners and also it

is a high level language meaning it can be used in a variety of scenarios.

5. User-friendly data structure:

Amrita vidyalayam, kanyakumari 8


Python has built in data-structures like list, dictionary, tuple etc. and also the

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

support code that is needed.

6. Productivity and speed:

Python is an object-oriented language , provides enhanced process and control

capabilities and possesses strong integration and text processing capabilities

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

complex multi-protocol network applications.

Python also has a robust standard library, which enables web programmer to

Accomplish common programming tasks like web service implementation,

String operation etc. without writing additional code. They can use specific

frameworks to use Python for developing web applications, desktop GUI

applications, and scientific and numeric application and cross-platform mobile

apps. But Python, like other programming languages, has several

shortcomings. It’s essential for programmers to know some of the major

limitations of Python programming language.

Amrita vidyalayam, kanyakumari 9


Limitations of python programming language:

1) Performance and Speed

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

existing Python code to take advantage of the existing execution speed.

2) Incompatibility of Two Versions

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

popular frameworks and libraries that support only Python 2.

3) Application Portability

Python is a high-level programming language. So developers use interpreters to convert

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

Python is a dynamically typed programming language. It does not require programmers to

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.

5) Lacks Web Development Capabilities

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

frameworks additionally to effectuate web application development. However, they have

option to choose from several full-stack web frameworks for Python including Django,

TurboGear, web2py, Reahland and Zope2.

6) Weak in Mobile Computing

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

mobile apps using Python.

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.

8) No Option to Embed Block Comments

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.

9) Many Python Modules Lack Adequate Support

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

research to pick the right packages or modules.

10) Does not Provide Prebuilt Statistical Models and Tests

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 Syntax compared to other programming languages

 Python was designed for readability, and has some similarities to the

English language with influence from mathematics.

 Python uses new lines to complete a command, as opposed to other

programming languages which often use semicolons or parentheses.

 Python relies on indentation, using whitespace, to define scope; such

as the scope of loops, functions and classes. Other programming

languages often use curly-brackets for this purpose. time and effort to

assess the quality of Python code

1
Amrita vidyalayam, kanyakumari
3
Applications of python programming language:

 GUI based desktop application development

 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

2. Entering the food data

The details about the food taken at the particular part of the day as food name,

amount of food taken.

3. Viewing the data for a particular day

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 option “view the average calories burned this month”

6. Enter the path

The path needed to store the data is entered through this option “o”.

This is needed to be filled only once.

7. Exit

This is used for exiting the program

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():

global name_of_food, amount_of_food


path_boss = []
with open("godfather_path", 'r')as file:
target = csv.reader(file)
for lines in target:
path_boss.append(lines)

part_of_day = input("enter the time of day: ")


filename = part_of_day + " " + str(date.today())
fields = ["S.number", "part-of-day", "food_time", "name", "amount_of_food"]
rows = []
food_lst = []
no_of_food = int(input("enter the no.of food taken: "))
no_of_food_ml = no_of_food
now = datetime.now()
datelist = []
datelist.append(date.today())
todays_date = date.today()
path1 = str(todays_date.year) + str(todays_date.month)
path_storage = path_boss[0][0] + "/Data-DON'T-DELETE/"

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

filename = str(todays_date.year) + '-' + str(todays_date.month) + '-' + str(todays_date.day) + ''


+ part_of_day

# writing to csv file


with open(filename, 'w') as csv_file:
# creating a csv writer object
csvwriter = csv.writer(csv_file)

# writing the fields


csvwriter.writerow(fields)

# writing the data rows


csvwriter.writerows(food_lst)
csv_file.close()

shutil.move(path_boss[0][0] + "/" + str(filename), path_storage_day)

file = str(todays_date.year) + '-' + str(todays_date.month) + '-' + str(todays_date.day) + '' +


part_of_day
path_storage_ml = path_boss[0][0] + "/Data-DON'T-DELETE-ML/"
if not os.path.exists(path_storage_ml):
os.mkdir(path_storage_ml)
ml_list = []

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)

'''path_calorie_storage = path_boss[0][0] + "/Calories/"


path_calorie_storage_month = path_calorie_storage + str(todays_date.month)'''
calorie = []
if part_of_day == "night":
calories_lost = int(input("enter the calories burned today -- "))
calorie.append(calories_lost)
'''if not os.path.exists(path_calorie_storage_month):
os.mkdir(path_calorie_storage_month)'''
calories_filename = str(todays_date.day) + ' ' + str(todays_date.year)
with open(calories_filename, 'w')as file:
writer = csv.writer(file)
writer.writerow(calorie)
shutil.move(path_boss[0][0] + "/" + str(calories_filename), path_calorie_storage_month)

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)

with open("godfather_path", 'w') as file:


csv_writer = csv.writer(file)
csv_writer.writerow(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'])

for i in range(0, len(data)):


print(data[i][3], " - ", "time",' - ', data[i][2], " - ", (float(data[i][4])) * calorie[data[i][3]])

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)

for d in range(0, len(data)):


a = data[d]
for e in range(0, len(a)):
final_calorie += int(a[e])
print("the total calories burned this month : ", final_calorie)

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))

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'])

# 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)

final_dict = {count: item_count for count,


item_count in zip(count, item_count)}
for i in range(0, len(data)):
print(data[i][3], " - ", data[i][2], " - ", int(data[i][4]) * calorie[data[i][3]])
sum_calorie = 0
for i in range(0, len(data)):
sum_calorie += calorie[data[i][3]] * int(data[i][4])
avg_calorie = sum_calorie / len(data)
print("your average calorie intake this month is -- ", avg_calorie)
if avg_calorie < 2500:
print("if this trend is followed, there will be a loss of weight")
else:
print("if this trend is followed, there will be a increase in weight")
return avg_calorie

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!!''')

decision = input("Enter your input -- ")


if decision == '0':
god_input()
elif decision == '1':
app_input()
elif decision == '2':
app_output()
elif decision == '3':

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

2. sumita arora - computer science book for class 11

3
Amrita vidyalayam, kanyakumari
0

You might also like