From 38d397a5991a53e166098b35d26e98f8c89771b4 Mon Sep 17 00:00:00 2001 From: tlizri Date: Tue, 8 Nov 2022 21:01:46 +0100 Subject: [PATCH 1/2] Update README.md --- README.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/README.md b/README.md index fa0237d..9d84e1a 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # OpenBootCampPython Repository to store Python boot camp. + +Ejercicio 6.B: En este segundo ejercicio, tendréis que crear un programa que tenga una clase llamada Alumno que tenga como atributos su nombre y su nota. Deberéis de definir los métodos para inicializar sus atributos, imprimirlos y mostrar un mensaje con el resultado de la nota y si ha aprobado o no. From 7a0233695ee3efed65fb6c742b695fe91004104e Mon Sep 17 00:00:00 2001 From: tlizri Date: Tue, 8 Nov 2022 21:19:48 +0100 Subject: [PATCH 2/2] Completed exercise Six.B --- src/exercisesix/alumno.py | 48 +++++++++++++++++++++++++++++++++++++++ src/main.py | 11 +++++++-- 2 files changed, 57 insertions(+), 2 deletions(-) create mode 100644 src/exercisesix/alumno.py diff --git a/src/exercisesix/alumno.py b/src/exercisesix/alumno.py new file mode 100644 index 0000000..6f9d466 --- /dev/null +++ b/src/exercisesix/alumno.py @@ -0,0 +1,48 @@ +class Alumno: + """Conceptual representation of a student + """ + def __init__(self, nombre='', nota=-1): + """Constructor method + :param nombre: student name + :type nombre: str + :param nota: student mark + :type nota: float + """ + self.nombre = nombre + self.nota = float(nota) + + def asignarNombre(self, nombre=''): + """Method to assign a student name + :param nombre: student name + :type nombre: str + :return: None + :rtype: NoneType + """ + self.nombre = nombre + + def asignarNota(self, nota=-1): + """Method to assign a student mark + :param nota: student mark + :type nota: float + :return: None + :rtype: NoneType + """ + self.nota = float(nota) + + def verDatos(self): + """Method to show student data + :return: None + :rtype: NoneType + """ + print('Alumno:', self.nombre) + print('Calificacion:', self.nota) + + def estaAprovado(self): + """Method to check if the student pass or fail + :return: None + :rtype: NoneType + """ + if self.nota >= 5: + print('Aprobado') + else: + print('Suspenso') diff --git a/src/main.py b/src/main.py index a47b6a3..3b17f06 100644 --- a/src/main.py +++ b/src/main.py @@ -1,9 +1,16 @@ +from src.exercisesix.alumno import Alumno + + def main(): - """Main script for pythonBootCamp project + """Main script for exercise six.b :return: None :rtype: NoneType """ - pass + alumno = Alumno() + alumno.asignarNombre('Rafael') + alumno.asignarNota(10) + alumno.verDatos() + alumno.estaAprovado() if __name__ == '__main__':