20% OF THE PAYOUT TO @SIZ-OFFICIAL
Hello everyone. Today it's time to share another project of mine. I made a project of Database for gym. It's not made my SQL or any other neither it's that professional. I saved all the data in the list. It was a short project but believe me it took weeks to complete XD am again saying if you know python you would understand it easily. I've made the code in chunks so you won't find difficulty or read it easily.
DATA BASE FOR GYM MEMBERS
This code is designed to store data for the members of a gym. It stores name, registration number, contact number, CNIC number, height in inches, weight in kg, and also calculates the BMI each member.
FUNCTIONS:
The code enables the user to:
• Input as many records as he/she wants to store.
• Display the entered records.
• Save these records.
• Load the previously entered records.
• Search for a specific record.
The Code displays a menu in the start which allows the user to select the desired operation. Functions are called
as per the need of the user.
✓ Input Function:
This function allows the user to enter the
records which are stored in a list.
✓ Display Function:
This function displays the details of each
worker in a presentable manner.
✓ Save Function:
This function stores the data entered by the user in a file.
✓ Load function:
This loads all the previous records which
were entered in the past.
✓ Search Function:
This allows to search for a specific record by asking the name of the worker.
Code For Input Records:
print("WELCOME TO THE GYM MANAGEMENT SYSTEM")
list_of_records = []
def input_records(list_of_records):
while True:
reg_no = input("REGISTRATION NUMBER:")
name = input("NAME:")
contact = int(input("CONTACT:"))
cnic = int(input("CNIC NUMBER:"))
height = float(input("HEIGHT IN METERS"))
weight = float(input("WEIGHT IN KG"))
bmi = round(weight /( height * height),2)
print("BMI :", bmi)
list_of_records.append([reg_no, name, contact, cnic, height, weight, bmi])
choice = input("Enter 'y' or 'Y' to continue or any other button to register more")
if choice != "y" and choice != "Y":
break
Code to display the records:
def display_records(list_of_records):
serial = 1
for record in list_of_records:
print("SERIAL NUMBER :", serial)
print("REGISTRATION NUMBER :", record[0])
print("NAME :", record[1])
print("CONTACT :", record[2])
print("CNIC NUMBER :", (record[3]))
print("HEIGHT :", (record[4]))
print("WEIGHT :", (record[5]))
print("BMI :",(record[6]))
Code to save the records:
def save_records(list_of_records):
f = open("registration.txt", "w")
f.write(str(list_of_records))
f.close()
code to load the records:
def load_records(list_of_records):
f = open("registration.txt", "r")
list_of_records = eval(f.read())
f.close()
print(list_of_records)
Code to search:
def search(list_of_records):
rec=0
if len(list_of_records)==0:
print("The database has no records right now.")
else:
search=input("Enter the name to search record: ")
for i in range(0,len(list_of_records)):
if search == list_of_records[i][1]:
print ("The desired record is: ")
print("Registration: ", list_of_records[i][0])
print("Name: ",list_of_records[i][1])
print("contact: ",list_of_records[i][2])
print("CNIC: ", list_of_records[i][3])
print("Height: ",list_of_records[i][4])
print("Weight: ",list_of_records[i][5])
print ("BMI", list_of_records[i][6])
else:
rec+=1
if rec==(len(list_of_records)):
print("The desired record doesn't exist.")
Code to display the options:
while True:
print("""
1)ENTER
2)DISPLAY
3)SAVE)
4)LOAD)
5)SEARCH""")
choice = int(input("ENTER THE CHOICE NUMBER :"))
if choice == 1:
print(input_records(list_of_records))
elif choice == 2:
print(display_records(list_of_records))
elif choice == 3:
print(save_records(list_of_records))
elif choice == 4:
print(load_records(list_of_records))
elif choice == 5:
print(search(list_of_records ))
else:
print("ENTER THE CORRECT ONE !")
If you like python tutorials and projects. You would like my these posts as well.
BEST REGARDS
VVARISHAYY
Wao very nice 😊.it's very interesting for me also.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you!
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Good one tutorial dear friend you make a very good tutorial for beginners i am very happy to see your tutorials because it is very informative and well detailed.
You are doing a great work on this wonderful platform.
My best wishes for you.
Regards, Faran
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for reading 😊
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Its amazing. I think you are very interested in programming. Thanks for this informative post
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
Thank you for reading :)
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit
That is a simple yet great implementation from your side. It cover's the basic menu and needs of the customer.
I have the problem till date that I have to think hard about what other creative options I can implement for the users so that my program outstands other's.
Downvoting a post can decrease pending rewards and make it less visible. Common reasons:
Submit