Click here to Skip to main content
15,881,812 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
Description: in function of the Football World Cup, a friend requested you to do a program that helps you manage information about the competition.
To do this, you must implement this program in Python, which you must use
text file(s), to store data regarding teams and games.
• Display a menu for the user to select what they want to do, with the following options:
1. Exit the program.
2. New team.
Read the data of the teams (Country, abbreviation, group);
Multiple teams can be added before saving to the file, and
none of them should be lost;
3. New Game.
Read the game data (teams, goals of each team and fouls);
Multiple games can be added before saving to the archive,
and none of them should be lost;
4. Total number of games stored in the" Bank " of the World Cup.
Display the total number of saved matches in the file;
5. Total number ofteams on the "bench" of the World Cup.
Display the total number of teams saved in the file;
6. Write game data to file;
Record the information in two separate files (teams and games)
If there is already information saved in the "bank", these should not be
lose;
7. List of games on the bench and their respective teams;
Display all matches with the teams and their respective number of goals and
faults in the archives;
At the end display the total number of games listed;
• The main program must call at least 6 functions or procedures to
perform the activities referred to in items 2 to 7 listed above.
• The main program should be displaying the menu and asking the user what
he wants to do until the option to quit is selected;
•Error control should be performed, to prevent the user from using, for example, the
option 10 as this does not exist
in the menu;
• Each team may have tied for multiple games;

NOTES
.Must have commentaries
.The code must work for any word inserted, including uppercase and lowercase

What I have tried:

Python
def menu():
    print('''
            MENU:

            [nova_equipe ou NOVA_EQUIPE ou Nova_Equipe ou Nova_equipe] - Cadastrar Nova Equipe
            [novo_jogo ou NOVO_JOGO ou Novo_Jogo ou Novo_jogo] - Cadastrar Novo Jogo
            [sair ou SAIR ou Sair] - Sair
        ''')

menu()
opçao = str(input('Escolha uma opção: '))
if opçao == "nova_equipe" or opçao == "NOVA_EQUIPE" or opçao == "Nova_Equipe" or opçao == "Nova_equipe":
    while (opçao == True):
        numero_equipes = 1
        print("Você selecionou a opção para cadastrar uma nova equipe")
        equipe = str(input("Digite o nome da equipe: "))
        país = str(input("Informe o país de origem: "))
        abreviacao = str(input("Digite a abreviação do nome da equipe: "))
        grupo = str(input("Informe o grupo a qual a equipe pertence: "))
        equipes = open("equipes.txt", "w")
        equipes.write(f"Nome da equipe: {equipe} \n País: {país} \n Abreviação: {abreviacao} \n grupo: {grupo} \n")
        equipes.close()
        print(equipes)
        banco = open("banco.txt", "w")
        banco.write(f"Número Total de Equipes: {numero_equipes} \n")
        banco.close()
        escolha = str(input("deseja cadastrar mais uma equipe? Se sim, digite 'outra_equipe'. Se não, digite 'sair_do_cadastro'."))
        if escolha == "sair_do_cadastro" or escolha == "SAIR_DO_CADASTRO" or escolha == "Sair_do_Cadastro" or escolha == "Sair_do_cadastro":
            break
        elif escolha == "outra_equipe" or "OUTRA_EQUIPE" or "Outra_Equipe" or "Outra_equipe":
            for escolha in True:
                numero_equipes += 1
                n = 2
                equipe = str(input(f"Digite o nome da {n}° equipe: "))
                país = str(input("Informe o país de origem: "))
                abreviacao = str(input("Digite a abreviação do nome da equipe: "))
                grupo = str(input("Informe o grupo a qual a equipe pertence: "))
                equipes = open("equipes.txt", "a+")
                equipes.write(f"Nome da equipe: {equipe} \n País: {país} \n Abreviação: {abreviacao} \n grupo: {grupo} \n")
                equipes.close()
                print(equipes)
                banco = open("banco.txt", "a+")
                banco.write(f"Número Total de Equipes: {numero_equipes} \n")
                banco.close() 
                n += 1
elif opçao == "novo_jogo" or opçao == "NOVO_JOGO" or opçao == "Novo_Jogo" or opçao == "Novo_jogo":
    while (opçao == True):
        numero_jogos = 1
        print("Você selecionou a opção para cadastrar um novo jogo")
        times = str(input("Informe as equipes que participam do jogo: "))
        gols = str(input("Digite o placar do jogo, informando qual equipe fez cada gol: "))
        faltas_amarelas = int(input("Digite quantas faltas amarelas ocorreram no jogo, informando qual equipe fez cada uma: "))
        faltas_vermelhas = int(input("Digite quantas faltas vermelhas ocorreram no jogo, informando qual equipe fez cada uma: "))
        jogos = open("jogos.txt", "w")
        jogos.write(f"Times: {times} \n Placar: {gols} \n Faltas: {faltas_amarelas} Amarelas e {faltas_vermelhas} Vermelhas \n")
        jogos.close()
        print(jogos)
        banco = open("banco.txt", "a+")
        banco.write(f"Número Total de Jogos: {numero_jogos} \n")
        banco.close() 
        escolha = str(input("deseja cadastrar mais um jogo? Se sim, digite 'outro_jogo'. Se não, digite 'sair_do_cadastro'."))
        if escolha == "sair_do_cadastro" or escolha == "SAIR_DO_CADASTRO" or escolha == "Sair_do_Cadastro" or escolha == "Sair_do_cadastro":
            break
        elif escolha == "outro_jogo" or "OUTRO_JOGO" or "Outro_Jogo" or "Outro_jogo":
            for escolha in True:
                numero_jogos += 1
                n = 2
                print("Você selecionou a opção para cadastrar um novo jogo")
                times = str(input("Informe as equipes que participam do jogo: "))
                gols = str(input("Digite o placar do jogo, informando qual equipe fez cada gol: "))
                faltas_amarelas = int(input("Digite quantas faltas amarelas ocorreram no jogo, informando qual equipe fez cada uma: "))
                faltas_vermelhas = int(input("Digite quantas faltas vermelhas ocorreram no jogo, informando qual equipe fez cada uma: "))
                jogos = open("jogos.txt", "a+")
                jogos.write(f"Times: {times} \n Placar: {gols} \n Faltas: {faltas_amarelas} Amarelas e {faltas_vermelhas} Vermelhas \n")
                jogos.close()
                print(jogos)
                banco = open("banco.txt", "a+")
                banco.write(f"Número Total de Jogos: {numero_jogos} \n")
                banco.close() 
                n += 1
        banco = open("banco.txt", "a+")
        equipes = equipes.open("equipes.txt", "r")
        jogos = jogos.open("jogos.txt", "r")
        banco.write(f"Equipes: {equipes} \n Jogos: {jogos} \n")  
        banco.close()   
        print(banco)
elif (opçao != "nova_equipe" and opçao != "NOVA_EQUIPE" and opçao != "Nova_Equipe" and opçao != "Nova_equipe") and (opçao != "novo_jogo" and opçao != "NOVO_JOGO" and opçao != "Novo_Jogo" and opçao != "Novo_jogo") and (opçao != "sair" and opçao != "SAIR" and opçao != "Sair"):
    print("Opção inexistente, escolha uma das opções informadas: ")  
elif opçao == "sair" or opçao == "SAIR" or opçao == "Sair":
    print("Você saiu do programa")
Posted
Updated 1-Dec-22 14:40pm
v2
Comments
OriginalGriff 2-Dec-22 0:52am    
"It doesn't work" is probably the most useless problem report we get - and we get it a lot. It tells us nothing about what is happening, or when it happens.
So tell us what it is doing that you didn't expect, or not doing that you did.
Tell us what you did to get it to happen.
Tell us any error messages.
Richard MacCutchan 2-Dec-22 4:33am    
And as all the questions and answers are in Portuguese, it is unlikely that anyone here can guess what the program is trying to do.
Member 15627495 2-Dec-22 5:37am    
you need to define a structure for looping through the menus and submenus.
to have a clean code.
def main():while(opçao != false): reset_display() init_display() filter_input() execute_input()


do you see where it goes ? your code will be easy to read and understand.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900