#Euros Goal Tracker#1. Create 4 1D arrays: team, goal, concede, points#2. Create a simple menu#Print the menu options#repeat until the user types "exit", include: #Add team #Update team #Sort teams #Exit#3 Create the add team procedure#4 Create the update team option (linear search)#5 Create the sort team procdure that will sort ALL the arrays based# on the factor chosen by the user eg: goal, concode, points# Print the array items in a nice way(no brackets etc)
Question
#Euros Goal Tracker#1. Create 4 1D arrays: team, goal, concede, points#2. Create a simple menu#Print the menu options#repeat until the user types "exit", include: #Add team #Update team #Sort teams #Exit#3 Create the add team procedure#4 Create the update team option (linear search)#5 Create the sort team procdure that will sort ALL the arrays based# on the factor chosen by the user eg: goal, concode, points# Print the array items in a nice way(no brackets etc)
Solution
This seems like a task to create a program in Python. Here's a simple implementation:
import numpy as np
# Step 1: Create 4 1D arrays
team = np.array([])
goal = np.array([])
concede = np.array([])
points = np.array([])
# Step 2: Create a simple menu
while True:
print("\nMenu options:")
print("1. Add team")
print("2. Update team")
print("3. Sort teams")
print("4. Exit")
choice = input("Enter your choice: ")
# Step 3: Add team procedure
if choice == '1':
team_name = input("Enter team name: ")
team_goals = int(input("Enter team goals: "))
team_concede = int(input("Enter team concede: "))
team_points = int(input("Enter team points: "))
team = np.append(team, team_name)
goal = np.append(goal, team_goals)
concede = np.append(concede, team_concede)
points = np.append(points, team_points)
# Step 4: Update team option
elif choice == '2':
team_name = input("Enter team name to update: ")
if team_name in team:
index = np.where(team == team_name)
team_goals = int(input("Enter team goals: "))
team_concede = int(input("Enter team concede: "))
team_points = int(input("Enter team points: "))
goal[index] = team_goals
concede[index] = team_concede
points[index] = team_points
else:
print("Team not found!")
# Step 5: Sort teams procedure
elif choice == '3':
sort_choice = input("Sort by: 1. Goals 2. Concede 3. Points: ")
if sort_choice == '1':
sorted_indices = np.argsort(goal)
elif sort_choice == '2':
sorted_indices = np.argsort(concede)
elif sort_choice == '3':
sorted_indices = np.argsort(points)
team = team[sorted_indices]
goal = goal[sorted_indices]
concede = concede[sorted_indices]
points = points[sorted_indices]
print("Teams: ", team)
print("Goals: ", goal)
print("Concede: ", concede)
print("Points: ", points)
# Exit
elif choice == '4':
break
else:
print("Invalid choice!")
This program will allow you to add teams, update team information, and sort teams based on goals, concede, or points. The program will continue to run until you choose to exit.
Similar Questions
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.