Muy buenas:
La verdad no entiendo muy bien lo de los años bisiestos en Python. Parece una función muy compleja y larga de hacer.
Un abrazo.http://www.subeimagenes.com/img/gdfghfhfghgj-7784.jpg
esDivisiblePor4 = anio % 4
esDivisiblePor100 = anio % 100
esDivisiblePor400 = anio % 400
if (esDivisiblePor400 or (esDivisiblePor4 and not esDivisiblePor100):
print 'Es bisiesto'
else:
print 'No es bisiesto'
anio=int(raw_input("Introduzca un año: "))
esDivisiblePor4 = not(anio % 4)
esDivisiblePor100 = not(anio % 100)
esDivisiblePor400 = not(anio % 400)
if (esDivisiblePor400 or (esDivisiblePor4 and not esDivisiblePor100)):
print 'Es bisiesto.'
else:
print 'No es bisiesto.'
anio = int(raw_input("Introduzca un año: "))
print "Es bisiesto." if (anio%400==0 or (anio%4==0 and anio%100!=0)) else "No es bisiesto."
def es_bisiesto(n):
while n%4==0:
if (n%100!=0 and n%400==0) or(n%100==0 and n%400==0):
return("es bisiesto")
elif n%100!=0:
return("es bisiesto")
else :
return("NO es bisiesto")
return("No es bisiesto")
n=int(input("Introduce el año"))
print("El año es:",es_bisiesto(n))
def devuelve_dias(n):
if es_bisiesto(n):
return("366 dias")
else:
return("365 dias")
print("El nº de dias son:",devuelve_dias(n))
Volver a Sobre lenguajes de programación
Usuarios navegando por este Foro: No hay usuarios registrados visitando el Foro y 1 invitado