Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
36 changes: 36 additions & 0 deletions Dallia_Sintique/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
## Sistema de Informações de Alunas
## ****Escola REprograma****
![enter image description here](https://raw.githubusercontent.com/reprograma/on34-python-s05-projeto-guiado-I/main/assets/reprograma-fundos-claros.png)

Este é um sistema simples para obter e gerenciar informações de alunas, permite operações como inclusão de novas alunas, consulta de alunas cadastradas, consulta de faltas, consulta de notas e consulta de status de aprovação.

### Funcionalidades
1. Incluir uma nova aluna
Permite cadastrar uma nova aluna com informações como nome, sobrenome, turma, notas e presença.

2. Consultar lista de alunas
Exibe a lista de todas as alunas cadastradas no sistema.

3. Consultar faltas da aluna
Consulta e exibe o número de faltas de uma aluna específica, usando nome completo.

4. Consultar notas da aluna
Exibe as notas de uma aluna específica, usando nome completo.

5. Consultar status de aprovação
Verifica o status de aprovação de uma aluna com base em critérios como média de notas, percentual de presença e nota de participação.

6. Sair do sistema
Encerra a execução do programa.

### Para Uso
Ao executar o programa, você será apresentado ao menu onde poderá escolher uma das opções disponíveis digitando o número correspondente à operação desejada.

Certifique-se de seguir as instruções fornecidas pelo programa para cada tipo de entrada solicitada, de acordo com a ação desejada.

### Caso deseje executar o programa
- Faça o fork do repositório.
- Faça o clone na sua máquina(git clone)
- Abra o seu terminal
- Navegue até a pasta Dallia_Sintique
- Acesse o arquivo sistema_notas.py e execute no terminal.
Binary file not shown.
62 changes: 62 additions & 0 deletions Dallia_Sintique/dataset_alunas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,62 @@
dataset = {
("Ana", "Silva"): {
"Turma": "Turma A",
"Notas": [7.5, 4.0, 6.0],
"Presença": [True, True, False, True, True],
"Participação": 8.5
},
("Mariana", "Santos"): {
"Turma": "Turma B",
"Notas": [6.0, 7.5, 8.5],
"Presença": [True, True, True, False, True],
"Participação": 7.2
},
("Carla", "Oliveira"): {
"Turma": "Turma A",
"Notas": [8.0, 7.5, 8.5],
"Presença": [True, True, True, True, True],
"Participação": 8.2
},
("Juliana", "Ferreira"): {
"Turma": "Turma C",
"Notas": [9.0, 8.5, 7.0],
"Presença": [True, True, True, True, True],
"Participação": 8.7
},
("Patrícia", "Souza"): {
"Turma": "Turma B",
"Notas": [7.0, 7.0, 7.5],
"Presença": [True, False, True, True, True],
"Participação": 7.2
},
("Aline", "Martins"): {
"Turma": "Turma A",
"Notas": [8.5, 8.0, 9.0],
"Presença": [True, True, True, True, True],
"Participação": 8.5
},
("Fernanda", "Costa"): {
"Turma": "Turma C",
"Notas": [6.5, 7.0, 8.0],
"Presença": [True, True, True, False, True],
"Participação": 5.5
},
("Camila", "Pereira"): {
"Turma": "Turma B",
"Notas": [7.5, 8.0, 8.5],
"Presença": [True, True, True, True, True],
"Participação": 8.0
},
("Luana", "Rodrigues"): {
"Turma": "Turma A",
"Notas": [9.0, 9.0, 8.5],
"Presença": [True, True, True, True, True],
"Participação": 8.8
},
("Beatriz", "Lima"): {
"Turma": "Turma C",
"Notas": [8.0, 7.5, 7.0],
"Presença": [True, True, False, False, False],
"Participação": 7.5
}
}
177 changes: 177 additions & 0 deletions Dallia_Sintique/sistema_notas.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,177 @@
from dataset_alunas import dataset

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 obtem_nome(pergunta):
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ótimo uso de funções para encapsular a funcionalidade de obter nome e sobrenome de aluna e tratar o dado :)

while True:
entrada_usuário = str(input(pergunta)).lstrip().rstrip()
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

  1. Quando utilizamos o input, já estamos recebendo uma string, assim, não precisamos utilizar uma conversão de dados str :)
  2. Para não precisar utilizar um lstrip e um rstrip, podemos usar o strip, e ele já remove os espaços no início e final da string

Sugestão:

Suggested change
entrada_usuário = str(input(pergunta)).lstrip().rstrip()
entrada_usuário = input(pergunta).strip()

if entrada_usuário.replace(" ", "").isalpha() and entrada_usuário != "":
break
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ao invés de dar break, podemos retornar o entrada_usuário já neste ponto :)

Sugestão:

Suggested change
break
return entrada_usuário

else:
print("Digite um nome válido")
return entrada_usuário

def obtem_nota(numero_nota, tipo):
status = 0
while status == 0:
Comment on lines +34 to +35
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como a condição de saída já está dentro do bloco, podemos colocar o return no ponto que queremos. Assim, não necessitamos utilizar uma variável de controle.

Sugestão:

Suggested change
status = 0
while status == 0:
while True:

try:
if tipo == 'n':
nota = float(input(f"Digite a nota {numero_nota} da aluna) (0 a 10): "))
else:
nota = float(input(f"Digite a nota de participação da aluna) (0 a 10): "))
if nota >= 0 and nota <= 10:
status = 1
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como comentei, ao invés de colocar status 1 aqui, podemos apenas dar o return da função aqui.

Sugestão:

Suggested change
status = 1
return nota

else:
print("Digite uma nota válida entre 0 e 10")
except:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Como estamos utilizando valores, podemos especificar a except:

Sugestão:

Suggested change
except:
except ValueError:

print(" Entrada inválida. Digite um número inteiro entre 0 e 10")
return nota

def obtem_presenca(num_presenca):
contador = 0
while contador == 0:
Comment on lines +50 to +51
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Assim como na função de notas, podemos usar o while True pra facilitar o controle de fluxo:

Sugestão:

Suggested change
contador = 0
while contador == 0:
while True:

presenca = input(f"Digite a presença {num_presenca} da aluna apenas com (True ou False): ").strip()
if presenca.lower() in ['true', 'false']:
presenca = presenca.lower() == 'true'
contador = 1
Comment on lines +54 to +55
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podemos dar return neste ponto, sem precisar atribuir a uma variável

Sugestão:

Suggested change
presenca = presenca.lower() == 'true'
contador = 1
return presenca.lower() == 'true'

else:
print("Entrada inválida, informe a presença apenas com (True ou False)")
return presenca


def incluir_nova_aluna():
print('Iniciando cadastro de nova aluna ')
notas = []
presencas = []

nome = obtem_nome(" Informe o nome da aluna para cadastro: ").title()
sobrenome = obtem_nome (" Informe o sobrenome da aluna para cadastro: ").title()
nome_sobrenome = (nome, sobrenome)

while True:
turma = (input ('Informe a turma da aluna com A / B ou C: ')).strip().upper()
if turma == "A" or turma == "B" or turma == 'C':
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Aqui temos uma condicional de uma mesma variável validando para mais de um valor, podemos incluí-lo em uma lista :)

Sugestão:

Suggested change
if turma == "A" or turma == "B" or turma == 'C':
if turma in ['A', 'B', 'C']:

break
else:
print('Entrada inválida. Informe uma turma com ( A / B ou C )')


for i in range (1, 4):
nota = obtem_nota(i, 'n')
notas.append(nota)

for i in range (1, 6 ):
presenca = obtem_presenca(i)
presencas.append(presenca)

participacao = obtem_nota(0,'p')

dataset[nome_sobrenome] = {
"Turma": turma ,
"Notas": notas,
"Presença": presencas ,
"Participação": participacao
}
print("Aluna cadastrada com sucesso ")


def consultar_lista_alunas():
print(' Segue a lista de alunas cadastradas ')
if len(dataset) != 0:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Podemos simplificar a validação utilizando a própria coleção.

Sugestão:

Suggested change
if len(dataset) != 0:
if dataset:

for nome in dataset.keys():
print(nome[0])
Comment on lines +100 to +101
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Apenas para curiosidade, podemos desempacotar a tupla dando nome aos respectivos campos, assim não precisariamos usar o índice da tupla :)

Sugestão:

Suggested change
for nome in dataset.keys():
print(nome[0])
for nome, sobrenome in dataset.keys():
print(f"{nome} {sobrenome}")

else:
print("Não existem alunas cadastradas")

def consultar_faltas_aluna():
try:
nome_completo = tuple(obtem_nome('Informe o nome completo da aluna: ').title().split())

faltas_alunas = dataset[nome_completo]["Presença"]

numero_faltas = faltas_alunas.count(False)
print(f' A aluna {nome_completo[0]} , tem {numero_faltas} faltas')
except KeyError:
print(" Não localizado. Por favor informe o nome completo de uma aluna: ")


def consultar_notas_aluna():
try:
nome_completo = tuple(obtem_nome('Informe o nome completo da aluna: ').title().split())

notas_aluna = dataset[nome_completo]['Notas']

conte_nota = 0
for nota in notas_aluna:
conte_nota += 1
print(f' A nota {conte_nota} da aluna {nome_completo[0]} é: {nota}')
Comment on lines +123 to +126
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A função for já enumera sozinho, para recuperar o valor, é só utilizar o enumerate. Assim, não precisamos utilizar o contador e deixamos o código mais limpo.

Sugestão:

Suggested change
conte_nota = 0
for nota in notas_aluna:
conte_nota += 1
print(f' A nota {conte_nota} da aluna {nome_completo[0]} é: {nota}')
for i, nota in enumerate(notas_aluna, start=1):
print(f'A nota {i} da aluna {nome_completo[0]} é: {nota}')


except KeyError:
print("Não localizado. Por favor informe o nome completo de uma aluna: ")


def consultar_status_aprovacao():
try:
nome_completo = tuple(obtem_nome('Informe o nome completo da aluna: ').title().split())

notas_aluna = dataset[nome_completo]['Notas']
media_aluna = round(sum(notas_aluna)/len(notas_aluna),1)


presença_aluna = dataset[nome_completo]['Presença']
numero_presenca = presença_aluna.count(True)
porcentagem_presenca = round((numero_presenca/len(presença_aluna)) *100)

nota_participação = dataset[nome_completo]['Participação']

if media_aluna >=6 and porcentagem_presenca >= 80 and nota_participação >=6:
print(f' Aluna aprovada. \n Média Final: {media_aluna}')
elif media_aluna <6:
print(f' Aluna Reprovada por média inferior a 6.0 \n Média Final Obtida: {media_aluna}')
elif nota_participação < 6:
print(f' Aluna Reprovada por nota de participação inferior a 6.0 \n Nota de participação obtida: {nota_participação}. \n Média Final: {media_aluna} ')
else:
print(f' Aluna Reprovada por presença inferior a 80%.\n A presença da aluna foi de {porcentagem_presenca}% \n Média Final: {media_aluna}')
except KeyError:
print("Não localizado. Por favor informe o nome completo de uma aluna")
Comment on lines +132 to +155
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Boa implementação do cálculo de aprovação, cuidado com as quebras de linhas adicionais e foi muito legal você ter adicionado uma mensagem pra cada tipo de reprovação. No geral, foi tudo bem testado. Parabéns pelo trabalho! :)


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

main()
21 changes: 21 additions & 0 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -0,0 +1,21 @@
MIT License

Copyright (c) 2024 Dállia Sintique Reis

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.