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
2 changes: 2 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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.
48 changes: 48 additions & 0 deletions src/exercisesix/alumno.py
Original file line number Diff line number Diff line change
@@ -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')
11 changes: 9 additions & 2 deletions src/main.py
Original file line number Diff line number Diff line change
@@ -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__':
Expand Down