-
Notifications
You must be signed in to change notification settings - Fork 38
Entrega do projeto guiado I da semana 5. #17
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| @@ -0,0 +1,141 @@ | ||||||||||||||||||
| from dataset_alunas import dataset | ||||||||||||||||||
|
|
||||||||||||||||||
| def main(): | ||||||||||||||||||
| print("\n--- Seja bem vinda a Escola do Reprograma! ---") | ||||||||||||||||||
| print("Sistema de informações de alunas") | ||||||||||||||||||
|
|
||||||||||||||||||
| while True: | ||||||||||||||||||
| cod_opcao = obter_opcao() | ||||||||||||||||||
|
|
||||||||||||||||||
| if cod_opcao == 1: incluir_nova_aluna() | ||||||||||||||||||
| elif cod_opcao == 2: consultar_lista_alunas() | ||||||||||||||||||
| elif cod_opcao == 3: consultar_faltas_aluna() | ||||||||||||||||||
| elif cod_opcao == 4: consultar_notas_aluna() | ||||||||||||||||||
| elif cod_opcao == 5: consultar_status_aprovacao() | ||||||||||||||||||
| elif cod_opcao == 6: print("Encerrando o programa..."); break | ||||||||||||||||||
|
|
||||||||||||||||||
| def obter_opcao(): | ||||||||||||||||||
| codigo_opcao = 0 | ||||||||||||||||||
|
|
||||||||||||||||||
| while codigo_opcao not in [1, 2, 3, 4, 5, 6]: | ||||||||||||||||||
| try: | ||||||||||||||||||
| codigo_opcao = int(input("\nEscolha uma opção:\n" | ||||||||||||||||||
| "1 - Incluir uma nova aluna\n" | ||||||||||||||||||
| "2 - Consultar lista de alunas\n" | ||||||||||||||||||
| "3 - Consultar faltas da aluna\n" | ||||||||||||||||||
| "4 - Consultar notas da aluna\n" | ||||||||||||||||||
| "5 - Consultar status de aprovação\n" | ||||||||||||||||||
| "6 - Sair do sistema\n" | ||||||||||||||||||
| "Opção: ")) | ||||||||||||||||||
|
|
||||||||||||||||||
| if codigo_opcao not in [1, 2, 3, 4, 5, 6]: | ||||||||||||||||||
| print("Opção inválida. Por favor, escolha uma opção válida (1 a 5).\n") | ||||||||||||||||||
| except ValueError: | ||||||||||||||||||
| print("Entrada inválida. Por favor, digite um número inteiro.\n") | ||||||||||||||||||
|
|
||||||||||||||||||
| return codigo_opcao | ||||||||||||||||||
|
|
||||||||||||||||||
| def incluir_nova_aluna(): | ||||||||||||||||||
| print("\nInsira os dados da aula! ") | ||||||||||||||||||
| nome = input("Nome da aluna:") | ||||||||||||||||||
| sobrenome = input("Sobrenome da aluna: ") | ||||||||||||||||||
| turma = input("Turma da aluna: ") | ||||||||||||||||||
| notas = obter_nota() | ||||||||||||||||||
| presenca = obter_presenca() | ||||||||||||||||||
| participacao = float(input("Nota de participação da aluna: ")) | ||||||||||||||||||
|
|
||||||||||||||||||
| salvar_dados_alunas(nome, sobrenome, turma, notas, presenca, participacao) | ||||||||||||||||||
|
|
||||||||||||||||||
| return nome | ||||||||||||||||||
|
|
||||||||||||||||||
| def obter_nota(): | ||||||||||||||||||
| quantidade_notas = input("Quantas notas deseja inserir? ") | ||||||||||||||||||
| notas = [] | ||||||||||||||||||
|
|
||||||||||||||||||
| for i in range(int(quantidade_notas)): | ||||||||||||||||||
| while True: | ||||||||||||||||||
| entrada = input(f"Insira a nota {i + 1}: ") | ||||||||||||||||||
| try: | ||||||||||||||||||
| nota = float(entrada) | ||||||||||||||||||
| notas.append(nota) | ||||||||||||||||||
| break | ||||||||||||||||||
| except ValueError: | ||||||||||||||||||
| print("Entrada inválida. Por favor, insira true ou false.") | ||||||||||||||||||
|
Comment on lines
+58
to
+63
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bom uso da validação para inserir a nota da aluna. |
||||||||||||||||||
|
|
||||||||||||||||||
| return notas | ||||||||||||||||||
|
|
||||||||||||||||||
| def obter_presenca(): | ||||||||||||||||||
| quantidade_aulas = input("Insira a quantidade de aulas da aluna: ") | ||||||||||||||||||
| presenca = [] | ||||||||||||||||||
|
|
||||||||||||||||||
| for i in range(int(quantidade_aulas)): | ||||||||||||||||||
| while True: | ||||||||||||||||||
| entrada = input(f"Presença na aula {i + 1} (True/False): ") | ||||||||||||||||||
| if entrada.lower() == 'true': | ||||||||||||||||||
| presenca.append(True) | ||||||||||||||||||
| break | ||||||||||||||||||
| elif entrada.lower() == 'false': | ||||||||||||||||||
| presenca.append(False) | ||||||||||||||||||
| break | ||||||||||||||||||
| else: | ||||||||||||||||||
| print("Entrada inválida. Por favor, digite 'True' ou 'False'.") | ||||||||||||||||||
|
Comment on lines
+71
to
+81
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excelente implementação da obtenção de presença das alunas. |
||||||||||||||||||
|
|
||||||||||||||||||
| return presenca | ||||||||||||||||||
|
|
||||||||||||||||||
| def salvar_dados_alunas(nome, sobrenome, turma, notas, presenca, participacao): | ||||||||||||||||||
| chave = (nome, sobrenome) | ||||||||||||||||||
| dataset[chave] = { | ||||||||||||||||||
| "Turma": turma, | ||||||||||||||||||
| "Notas": notas, | ||||||||||||||||||
| "Presença": presenca, | ||||||||||||||||||
| "Participação": participacao, | ||||||||||||||||||
| } | ||||||||||||||||||
|
|
||||||||||||||||||
| print(f"Aluna {nome} {sobrenome} adicionada com sucesso!") | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| def consultar_lista_alunas(): | ||||||||||||||||||
| if dataset: | ||||||||||||||||||
| print("\nAlunas cadastradas:") | ||||||||||||||||||
| for nome in dataset: | ||||||||||||||||||
| print(nome) | ||||||||||||||||||
|
Comment on lines
+100
to
+101
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. No requisito funcional, era esperado que a impressão dos nomes das alunas estivesse formatado. Do modo como está, ele está imprimindo a tupla de forma crua. Sugestão:
Suggested change
|
||||||||||||||||||
| else: | ||||||||||||||||||
| print("\nNão há alunas cadastradas.") | ||||||||||||||||||
|
|
||||||||||||||||||
| def consultar_faltas_aluna(): | ||||||||||||||||||
| nome_aluna = input("Insira o nome completo da aluna: ") | ||||||||||||||||||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. O recebimento do nome da aluna está incorreto, o que causa erro nesta e nas demais funções. Acredito que o projeto não foi testado de forma apropriada. Neste caso, o nome que estamos recebendo é uma string. Por Exemplo: Sugestão:
Suggested change
Podemos receber desta forma, ou usar a função split para separar a string:
Suggested change
|
||||||||||||||||||
| if nome_aluna in dataset: | ||||||||||||||||||
| faltas = dataset[nome_aluna]["Presença"].count(False) | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} teve {faltas} faltas.") | ||||||||||||||||||
| else: | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} não foi encontrada.") | ||||||||||||||||||
|
|
||||||||||||||||||
| def consultar_notas_aluna(): | ||||||||||||||||||
| nome_aluna = input("Insira o nome completo da aluna: ") | ||||||||||||||||||
| if nome_aluna in dataset: | ||||||||||||||||||
| notas = dataset[nome_aluna]["Notas"] | ||||||||||||||||||
| print(f"\nAs notas da aluna {nome_aluna} são: {notas}") | ||||||||||||||||||
| else: | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} não foi encontrada.") | ||||||||||||||||||
|
Comment on lines
+115
to
+119
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A implementação está correta, mas a função não consegue encontrar as alunas por causa do input. |
||||||||||||||||||
|
|
||||||||||||||||||
| def consultar_status_aprovacao(): | ||||||||||||||||||
| nome_aluna = input("Insira o nome completo da aluna: ") | ||||||||||||||||||
|
|
||||||||||||||||||
| if nome_aluna in dataset: | ||||||||||||||||||
| dados_aluna = dataset[nome_aluna] | ||||||||||||||||||
| notas = dados_aluna.get("Notas", []) | ||||||||||||||||||
| presenca = dados_aluna.get("Presença", []) | ||||||||||||||||||
| participacao = dados_aluna.get("Participação", 0) | ||||||||||||||||||
|
Comment on lines
+126
to
+128
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Excelente implementação com a função get. |
||||||||||||||||||
|
|
||||||||||||||||||
| media = sum(notas) / len(notas) if notas else 0 | ||||||||||||||||||
| presenca_percentual = (presenca.count(True) / len(presenca)) * 100 if presenca else 0 | ||||||||||||||||||
|
Comment on lines
+130
to
+131
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bom trabalho com uso de operador ternário |
||||||||||||||||||
|
|
||||||||||||||||||
| if media >= 6.0 and presenca_percentual >= 80 and participacao > 6: | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} está Aprovada com média {media:.2f}.") | ||||||||||||||||||
| else: | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} está Reprovada com média {media:.2f}.") | ||||||||||||||||||
| else: | ||||||||||||||||||
| print(f"\nA aluna {nome_aluna} não foi encontrada.") | ||||||||||||||||||
|
|
||||||||||||||||||
|
|
||||||||||||||||||
| main() | ||||||||||||||||||
This file was deleted.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ótima implementação, usou a estrutura que vimos em aula e fez um bom trabalho :)