Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 2

COMPUTER 8 – Hands-on Activity 4

### List Of Sports


sports = ["Volleyball", “Football”, “Cricket”, “Badminton”, “Basketball”]

### Procedure definitions


def add():
new = input("Add a sport ")
sports.append(new)
print(new, "has been added to the list. ")

def remove():
sport = input(“Which sport do you want to remove? ")
sports.remove(sport)
print(sport, "has been removed. ")

def search():
sport = input(“Types the name of sport you want to search. ")
if sport in sports:
print(sport, "is in the list. ")
else:
print(sport, "is not in the list. ") Name:____________________
def display(): Open Google Chrome
end = len(sports)
for i in range(end): Go to online-python.com
print(i, sports[i])
Create your own Python program
### Main program using the following commands:
select =""
while select != "X":  def
print("List Of Sports")  append
print("Add: Add a sport. ")
print("Remove: Remove a sport. ")  remove
print("Display: Check the sports. ")  print
print("Search: Search a specific sport. ")  input
print("Close: Close the program. ")
select = input("Select an option you want to do. ")  int
 if else
if select == "Add":  for
add()
 while
if select == "Remove":
remove()

if select == "Search":
search()

if select == "Display”:
display()

1
2

You might also like