You are on page 1of 25

WILDLIFE

SANCTUARY

1.M.SIDDHARDHA-XII A-ROLL NO:20


2.E.DEVRAAG-XII A-ROLL NO:10
3.SUSHANK SAHIL-XII A-ROLL NO:38
UNDERTAKING
We declare that the work presented in this project titled
“WILDLIFE SANCTUARY ”, submitted to
SMT.HEMALATHA PGTComputer Science
KENDRIYA VIDYALAYA TIRUMALAGIRI for the
award of the CBSE - AISSE class XII certificate. We
have not plagiarized or submitted the same work for the
award of any other examination. In case this
undertaking is found incorrect, we accept that our
Certificates may be unconditionally withdrawn.
1.M.SIDDHARDHA-XII A-ROLL NO:20
2.E.DEVRAAG-XII A-ROLL NO:10
3.SUSHANK SAHIL-XII A-ROLL NO:38
CERTIFICATE
Certified that the work contained in the
project titled “WILDLIFE
SANCTUARY ”, by:
“M.SIDDHARDHA,E.DEVRAAG,SH
USHANK SAHIL ”, has been carried
out under my supervision and that this
work has not been submitted elsewhere
for a AISSE certificate.

SMT HEMALATHA
CONTENTS
ACKNOWLEDGEMENTS
INTRODUCTION
PHYTHON CODING
CODE1-(txt)
CODE2-(CSV)
CODE3-(BINARY)
OUTPUT FOR THE CODES
INFERENCE
ACKNOWLEDGEMENT
We would like to thank
Sh.K.CHANDRASHEKAR RAO, Principal
Kendriya Vidyalaya Palampur. We are
deeply indebted to our mentor Smt
HEMALATHA. We further thank to all the
staff members of Kendriya
VidyalayaTirumalagiri. We owe our sincere
gratitude towards Kendriya Vidyalaya
Sangathan. Our heartfelt thanks to CBSE.
We also express our deepest gratitude to our
parents. Finally, we would like to wind up
by paying our heartfelt thanks to all our near
and dear ones.
1.M.SIDDHARDHA-XII A-ROLL NO:20
2.E.DEVRAAG-XII A-ROLL NO:10
3.SUSHANK SAHIL-XII A-ROLL NO:38
Introduction of the Project
We the students of CLASS XII A of
KENDRIYA VIDYALAYA TIRUMALAGIRI
have been assigned the work of WILDLIFE
SANCTUARY. To perform this task we have
been assigned the work of coding,analyzing
the overall mistakes and have done the
conclusion work.
We are so glad that this work have been assigned
to us, yet we haven’t done this work before .
Smt. HEMA LATHA our subject teacher have
also helped us a lot to complete this project. We
feel so blessed that we have learnt all this work
with the help of our ma’am,we are also thankful to
our respected principal K.CHANDRASHEKAR
RAO for providing us various facilities to
complete this project. As we are the students of
CLASS XII A and we haven’t done this type of
project before, we have performed all that which
we have learnt from our CBSE
PROGRAMMING .Hence, we know that this
programming would be further done on a big
platform. Since we have started this programming
from SEPTEMBER month ,we believe that this
programming would further help us a lot in our
future . We are also thankful to our groupmates for
cooperating with each other while performing this
task we have also polished the skills of group
activity. PROCESS FIRSTLY, we have done the
planning in a paper work regarding what have to
do on the assigned project WILD LIFE
SANCTUARY SECONDLY, we discussed our
planning with our subject teacher and then he
provided us the right path to perform the work.
NEXT, we started our project on foot paths of our
subject teacher. THEN, we started our coding,
coding took around 2 and half months for
completion. NEXT, we analyzed the mistakes done
and then we corrected them. THEN, we prepared
the project format as shown above. THANKS TO
ALL OF WORTHY TEACHERS AND
PRINCIPAL AND MY DEAR GROUP MATES
ALSO A GREAT THANKS TO KENDRIYA
VIDYALAYA SANGATHAN FOR PROVIDING
US THIS GOLDEN OPPORTUNITY
PYTHON CODING

CODE-1(txt)

# Function to write data to text file


def write_to_file(data):
with open('wildlife.txt', 'a') as file:
file.write(','.join(data) + '\n')

# Function to display all data


def display_data():
with open('wildlife.txt', 'r') as file:
for line in file:
print(line.strip().split(','))

# Function to search for data


def search_data(animal):
with open('wildlife.txt', 'r') as file:
for line in file:
data = line.strip().split(',')
if data[1].lower() == animal.lower():
return data
return None

# Function to update data


def update_data(animal, new_area):
with open('wildlife.txt', 'r') as file:
lines = file.readlines()

with open('wildlife.txt', 'w') as file:


for line in lines:
data = line.strip().split(',')
if data[1].lower() == animal.lower():
data[0] = new_area
file.write(','.join(data) + '\n')
else:
file.write(line)

# Function to delete data


def delete_data(animal):
with open('wildlife.txt', 'r') as file:
lines = file.readlines()

with open('wildlife.txt', 'w') as file:


for line in lines:
data = line.strip().split(',')
if data[1].lower() != animal.lower():
file.write(line)

# Main function
def main():
while True:
print("\n1. Add Data\n2. Display Data\n3. Search Data\n4. Update Data\n5.
Delete Data\n6. Exit")
choice = input("Enter your choice: ")

if choice == '1':
area = input("Enter area number: ")
animal = input("Enter animal name: ")
write_to_file([area, animal])
print("Data added successfully!")

elif choice == '2':


print("Wildlife Sanctuary Data:")
display_data()

elif choice == '3':


animal = input("Enter animal name to search: ")
result = search_data(animal)
if result:
print("Data found:", result)
else:
print("Data not found!")

elif choice == '4':


animal = input("Enter animal name to update: ")
new_area = input("Enter new area number: ")
update_data(animal, new_area)
print("Data updated successfully!")
elif choice == '5':
animal = input("Enter animal name to delete: ")
delete_data(animal)
print("Data deleted successfully!")

elif choice == '6':


print("Exiting program...")
break

else:
print("Invalid choice! Please enter a valid option.")

if __name__ == "__main__":
main()
CODE-2(csv)
import csv

# Function to write data to CSV


def write_to_csv(data):
with open('wildlife.csv', 'a', newline='') as file:
writer = csv.writer(file)
writer.writerow(data)

# Function to display all data


def display_data():
with open('wildlife.csv', 'r') as file:
reader = csv.reader(file)
print("Wildlife Sanctuary Data:")
for row in reader:
print(row)

# Function to search for data


def search_data(animal):
with open('wildlife.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
if row[1].lower() == animal.lower():
return row
return None

# Function to update data


def update_data(animal, new_area):
data = []
with open('wildlife.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
if row[1].lower() == animal.lower():
row[0] = new_area
data.append(row)
with open('wildlife.csv', 'w', newline='') as file:
writer = csv.writer(file)
writer.writerows(data)

# Function to delete data


def delete_data(animal):
data = []
with open('wildlife.csv', 'r') as file:
reader = csv.reader(file)
for row in reader:
if row[1].lower() != animal.lower():
data.append(row)

with open('wildlife.csv', 'w', newline='') as file:


writer = csv.writer(file)
writer.writerows(data)

# Main function
def main():
while True:
print("\n1. Add Data\n2. Display Data\n3. Search Data\n4. Update Data\n5.
Delete Data\n6. Exit")
choice = input("Enter your choice: ")

if choice == '1':
area = input("Enter area number: ")
animal = input("Enter animal name: ")
write_to_csv([area, animal])
print("Data added successfully!")

elif choice == '2':


display_data()

elif choice == '3':


animal = input("Enter animal name to search: ")
result = search_data(animal)
if result:
print("Data found:", result)
else:
print("Data not found!")

elif choice == '4':


animal = input("Enter animal name to update: ")
new_area = input("Enter new area number: ")
update_data(animal, new_area)
print("Data updated successfully!")

elif choice == '5':


animal = input("Enter animal name to delete: ")
delete_data(animal)
print("Data deleted successfully!")

elif choice == '6':


print("Exiting program...")
break

else:
print("Invalid choice! Please enter a valid option.")

if __name__ == "__main__":
main()

CODE3-(BINARY)
import pickle

# Function to write data to binary file


def write_to_file(data):
with open('wildlife.dat', 'ab') as file:
pickle.dump(data, file)

# Function to display all data


def display_data():
with open('wildlife.dat', 'rb') as file:
try:
while True:
print(pickle.load(file))
except EOFError:
pass

# Function to search for data


def search_data(animal):
with open('wildlife.dat', 'rb') as file:
try:
while True:
data = pickle.load(file)
if data[1].lower() == animal.lower():
return data
except EOFError:
pass
return None

# Function to update data


def update_data(animal, new_area):
data = 0
with open('wildlife.dat', 'rb') as file:
try:
while True:
entry = pickle.load(file)
if entry[1].lower() == animal.lower():
entry = (new_area, entry[1])
data.append(entry)
except EOFError:
pass

with open('wildlife.dat', 'wb') as file:


for entry in data:
pickle.dump(entry, file)
# Function to delete data
def delete_data(animal):
data = 0
with open('wildlife.dat', 'rb') as file:
try:
while True:
entry = pickle.load(file)
if entry[1].lower() != animal.lower():
data.append(entry)
except EOFError:
pass

with open('wildlife.dat', 'wb') as file:


for entry in data:
pickle.dump(entry, file)

# Main function
def main():
while True:
print("\n1. Add Data\n2. Display Data\n3. Search
Data\n4. Update Data\n5. Delete Data\n6. Exit")
choice = input("Enter your choice: ")

if choice == '1':
area = input("Enter area number:")
animal = input("Enter animal name: ")
write_to_file((area, animal))
print("Data added successfully!")

elif choice == '2':


display_data()

elif choice == '3':


animal = input("Enter animal name to search: ")
result = search_data(animal)
if result:
print("Data found:", result)
else:
print("Data not found!")
elif choice == '4':
animal = input("Enter animal name to update:")
new_area = input("Enter new area number: ")
update_data(animal, new_area)
print("Data updated successfully!")

elif choice == '5':


animal = input("Enter animal name to delete: ")
delete_data(animal)
print("Data deleted successfully!")

elif choice == '6':


print("Exiting program ... ")
break

else:
print("Invalid choice! Please enter a valid option.")

if _name _== "_main_":


main()
OUTPUT FOR THE ABOVE PHYTHON
CODES

DISPLAYING DATA
SEARCH DATA

UPDATE DATA

DELETE DATA
EXIT DATA
INFERENCE
 GEEKS FOR GEEKS
 Phython4csip

You might also like