import os
import time
def clear_terminal():
os.system(“cls” if os.name==“nt” else “clear”)
members_info={}
class Members:
def init(self,id,first_name,last_name,status):
self.id=id
self.first_name=first_name
self.last_name=last_name
self.status=status
def display():
if members_info:
for id in members_info:
print(f"First name:{members_info[id]["first name"]}")
print(f"Last name:{members_info[id]["last name"]}")
print(f"ID:{id}")
print(f"Status:{members_info[id]["status"]}")
print("-"*20)
else:
print("There is no members to show")
def search(members_info):
while True:
print("Search by:")
print("1)ID")
print("2)First name")
print("3)Status")
found_members={}
search_choice=input("enter your choice: ")
if search_choice=="1":
search_id=input("Enter ID: ")
if search_id in members_info:
for id in members_info:
if search_id==id:
print(f"First name:{members_info[search_id]["first name"]}")
print(f"Last name:{members_info[search_id]["last name"]}")
print(f"ID:{search_id}")
print(f"Status:{members_info[search_id]["status"]}")
print(f"-"*20)
break
else:
print("This ID isnot registered")
elif search_choice=="2":
search_name=input("Enter first name: ").lower()
for id in members_info:
if search_name==members_info[id]["first name"]:
found_members[id]={"first name":members_info[id]["first name"],
"last name":members_info[id]["last name"],
"status":members_info[id]["status"]}
if found_members:
for id in found_members:
print(f"First name:{found_members[id]["first name"]}")
print(f"Last name:{found_members[id]["last name"]}")
print(f"ID:{id}")
print(f"Status:{found_members[id]["status"]}")
print("-"*20)
else:
print("No members found")
break
elif search_choice=="3":
searched_status=input("Enter the status: ")
for id in members_info:
if searched_status==members_info[id]["status"]:
found_members[id]={"first name":members_info[id]["first name"],
"last name":members_info[id]["last name"],
"status":members_info[id]["status"]}
if found_members:
for id in found_members:
print(f"First name:{found_members[id]["first name"]}")
print(f"Last name:{found_members[id]["last name"]}")
print(f"ID:{id}")
print(f"Status:{found_members[id]["status"]}")
print("-"*20)
else:
print("No members found")
break
else:
print("Please enter a choice 1 or 2 or 3")
def add_members():
first_name=input("Enter your first name: ").lower()
last_name=input("Enter your last name: ").lower()
while True:
id=input("Enter your id: ")
if id not in members_info:
break
else:
print(“Please enter a valid ID”)
status=input("Enter your status os press enter: ")
if status==“active”:
status=“active”
else:
status=“inactive”
members_info[id]={“first name”:first_name,“last name”:last_name,“status”:status}
return members_info
while True:
print(" Welcome to gym membership system")
print(“1)Add members”)
print(“2)Display all members”)
print(“3)Search for a member”)
print(“4)Exit”)
choice=input("Please enter a choice from 1 to 4: ")
if choice==“1”:
clear_terminal()
add_members()
print(“Member added successfully”)
time.sleep(3)
elif choice==“2”:
clear_terminal()
Members.display()
elif choice==“3”:
clear_terminal()
if members_info:
Members.search(members_info)
else:
print(“There is no members found”)
elif choice==“4”:
print(“Exiting…”)
break
else:
print(“Please choose a valid choice”)