-
Notifications
You must be signed in to change notification settings - Fork 38
Projeto Guiado - Maria Camila #25
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 | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -36,24 +36,129 @@ def obter_opcao(): | |||||||||
| return codigo_opcao | ||||||||||
|
|
||||||||||
| def incluir_nova_aluna(): | ||||||||||
| pass | ||||||||||
| #TODO - Implentar a função | ||||||||||
|
|
||||||||||
| print("Por favor insira estes dados: ") | ||||||||||
| nome = input("Nome da aluna: ") | ||||||||||
| sobrenome = input("Sobrenome da aluna: ") | ||||||||||
| turma = input("Turma da aluna: ") | ||||||||||
| lista_presenca = obter_presenca() | ||||||||||
| nota_participacao = float(input("Participação da aluna: ")) | ||||||||||
| notas = obter_notas() | ||||||||||
|
|
||||||||||
| salvar_dados_aluna(nome, sobrenome, turma, lista_presenca, nota_participacao, notas) | ||||||||||
| print("Aluna adicionada com sucesso!") | ||||||||||
|
|
||||||||||
| def obter_presenca(): | ||||||||||
| quantidade_aulas = input("Quantidade de aulas: ") | ||||||||||
| aulas = [] | ||||||||||
|
|
||||||||||
| for contador in range(int(quantidade_aulas)): | ||||||||||
| while True: | ||||||||||
| entrada = input(f"Insira a presença da aula #{contador + 1} (True ou False): ") | ||||||||||
| if entrada in ["True", "False"]: | ||||||||||
| presenca = entrada == "True" | ||||||||||
| aulas.append(presenca) | ||||||||||
| break | ||||||||||
| else: | ||||||||||
| print("Entrada inválida. Por favor, insira True ou False.") | ||||||||||
|
|
||||||||||
| return aulas | ||||||||||
|
|
||||||||||
| def obter_notas(): | ||||||||||
| quantidade_notas = input("Quantidade de notas: ") | ||||||||||
| notas = [] | ||||||||||
|
|
||||||||||
| for contador in range(int(quantidade_notas)): | ||||||||||
| while True: | ||||||||||
| entrada = input(f"Insira a nota #{contador + 1}: ") | ||||||||||
| try: | ||||||||||
| nota = float(entrada) | ||||||||||
| if nota >= 0 and nota <= 10: | ||||||||||
| notas.append(nota) | ||||||||||
| break | ||||||||||
| else: | ||||||||||
| print("Nota inválida. Por favor, insira uma nota entre 0 e 10.") | ||||||||||
| continue | ||||||||||
| except ValueError: | ||||||||||
| print("Entrada inválida. Por favor, insira um número válido.") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| return notas | ||||||||||
|
|
||||||||||
| def salvar_dados_aluna(nome, sobrenome, turma, lista_presenca, nota_participacao, notas): | ||||||||||
| chave = f"{nome} {sobrenome}" | ||||||||||
|
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. Neste trecho o código está armazenando os dados no dicionário como uma chave de string concatenada, mas o formato esperado era uma tupla de dois elementos com (nome, sobrenome). Sugestão:
Suggested change
|
||||||||||
| dataset[chave] = { | ||||||||||
| "Nome": nome, | ||||||||||
| "Sobrenome": sobrenome, | ||||||||||
|
Comment on lines
+90
to
+91
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. Como utilizamos o nome e sobrenome na chave, não é necessário adicionar o nome e sobrenome do corpo do dicionário. |
||||||||||
| "Turma": turma, | ||||||||||
| "Notas": notas, | ||||||||||
| "Presença": lista_presenca, | ||||||||||
| "Participação": nota_participacao | ||||||||||
| } | ||||||||||
|
|
||||||||||
| def consultar_lista_alunas(): | ||||||||||
| pass | ||||||||||
| #TODO - Implentar a função | ||||||||||
|
|
||||||||||
| if not dataset: | ||||||||||
| print("Nenhuma aluna cadastrada.") | ||||||||||
| return | ||||||||||
|
|
||||||||||
| print("\nLista de alunas:") | ||||||||||
| for nome in dataset: | ||||||||||
| print(f"- {nome}") | ||||||||||
|
Comment on lines
+104
to
+105
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. Aqui o esperado é trazer o nome e sobrenome da aluna, não a tupla em si. É necessário buscar na relação das chaves do dicionário o valor no índice 0 e 1 da tupla ou dar nomes para cada um deles, desta forma: Sugestão:
Suggested change
|
||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| def consultar_faltas_aluna(): | ||||||||||
| pass | ||||||||||
| #TODO - Implentar a função | ||||||||||
| try: | ||||||||||
| nome = input("Nome da aluna: ") | ||||||||||
| sobrenome = input("Sobrenome da aluna: ") | ||||||||||
| lista_presenca = dataset[(nome, sobrenome)]["Presença"] | ||||||||||
| if (nome, sobrenome) in dataset: | ||||||||||
|
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. Neste ponto podemos remover esta validação, já que caso não tenha dados no dataset, já foi colocado uma exception. |
||||||||||
| print(f"A aluna {nome} {sobrenome} está com {lista_presenca}") | ||||||||||
|
|
||||||||||
| except: | ||||||||||
| print("Aluna não encontrada!") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def consultar_notas_aluna(): | ||||||||||
| pass | ||||||||||
| #TODO - Implentar a função | ||||||||||
| try: | ||||||||||
| nome = input("Nome da aluna: ") | ||||||||||
| sobrenome = input("Sobrenome da aluna: ") | ||||||||||
| notas_aluna = dataset[(nome, sobrenome)]["Notas"] | ||||||||||
| if (nome, sobrenome) in dataset: | ||||||||||
|
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. Neste ponto podemos remover esta validação, já que caso não tenha dados no dataset, já foi colocado uma exception. |
||||||||||
| print(f"A aluna {nome} {sobrenome} está com essas notas {notas_aluna}") | ||||||||||
|
|
||||||||||
| except: | ||||||||||
| print("Aluna não encontrada!") | ||||||||||
|
|
||||||||||
|
|
||||||||||
| def consultar_status_aprovacao(): | ||||||||||
| pass | ||||||||||
| #TODO - Implentar a função | ||||||||||
|
|
||||||||||
| def consultar_status_aprovacao(): | ||||||||||
| while True: | ||||||||||
| nome = input("Nome da aluna: ") | ||||||||||
| sobrenome = input("Sobrenome da aluna: ") | ||||||||||
|
|
||||||||||
| chave = (nome, sobrenome) | ||||||||||
|
|
||||||||||
| if chave in dataset: | ||||||||||
| dados = dataset[chave] | ||||||||||
| notas = dados["Notas"] | ||||||||||
| soma = sum(notas) | ||||||||||
|
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. Ao pensar em nomes de variáveis, avaliamos se o nome responde o que ela carrega como valor. Neste caso, poderiamos colocar "soma_notas". Não necessariamente precisaria estar isoladamente aqui, poderia ser calculado direto na nota_media também :) |
||||||||||
| participacao = dados["Participação"] | ||||||||||
| qtd_presenca = sum(dados["Presença"]) | ||||||||||
| percentual_presenca = qtd_presenca / len(dados["Presença"]) | ||||||||||
| nota_media = soma / len(notas) | ||||||||||
|
|
||||||||||
| print(f"A aluna {nome} {sobrenome} está com a nota média {nota_media:.2f}") | ||||||||||
|
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. Ótima formatação da saída! |
||||||||||
| if nota_media >= 6 and percentual_presenca >= 0.80 and participacao >= 6: | ||||||||||
| print("Aluna aprovada!!") | ||||||||||
| else: | ||||||||||
| print("Aluna reprovada!!") | ||||||||||
| else: | ||||||||||
| print("Aluna não encontrada no dataset.") | ||||||||||
|
|
||||||||||
| continuar = input("Deseja consultar outra aluna? (s/n): ") | ||||||||||
| if continuar.lower() != 's': | ||||||||||
| break | ||||||||||
|
|
||||||||||
|
|
||||||||||
|
|
||||||||||
| main() | ||||||||||
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.
Bom uso da lógica para guardar a presença :)