diff --git a/README.md b/README.md index fa0237d..2050495 100644 --- a/README.md +++ b/README.md @@ -1,2 +1,4 @@ # OpenBootCampPython Repository to store Python boot camp. +* Ejercicio 5: Escribe una función que pueda decirte si un año (número entero) es bisiesto o no. + * Path: 'src/ExerciseFive/isBisiesto.py' diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..ee2bf11 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,3 @@ +-i https://pypi.org/simple +setuptools==65.5.0 ; python_version >= '3.7' +wheel==0.38.0 diff --git a/src/exercisefive/bisiesto.py b/src/exercisefive/bisiesto.py new file mode 100644 index 0000000..d5c2471 --- /dev/null +++ b/src/exercisefive/bisiesto.py @@ -0,0 +1,15 @@ +def isbisiesto(year): + """Script to check if an input year is leap year + :param year: year to check if is leap year + :type year: int + :return: True if is leap year, False if is not + :rtype: bool + """ + if year % 4 != 0: + return False + elif year % 100 != 0: + return True + elif year % 400 != 0: + return False + else: + return True diff --git a/src/main.py b/src/main.py new file mode 100644 index 0000000..95a267c --- /dev/null +++ b/src/main.py @@ -0,0 +1,17 @@ +from src.exercisefive.bisiesto import isbisiesto + + +def main(): + """Main script for exercise five + :return: None + :rtype: NoneType + """ + year = input('Introduzca un año: ') + if isbisiesto(int(year)): + print('El año ' + year + ' es bisiesto') + else: + print('El año ' + year + ' no es bisiesto') + + +if __name__ == '__main__': + main()