Advertisement
Kyrexar

Calendario

Jul 23rd, 2013
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.74 KB | None | 0 0
  1. def esBisiesto(year): return year % 4 == 0 and year % 100 != 0 or year % 400 == 0
  2.  
  3. anyo=int(input("Calendario de: "))
  4. k=0
  5. while k<1 or k>7 :
  6.     k=int(input("El 1 de Enero de "+str(anyo)+" es (lunes=1, martes=2...): "))
  7.  
  8. if esBisiesto(anyo): n=29
  9. else: n=28
  10.  
  11. diasmeses=[31,n,31,30,31,30,31,31,30,31,30,31]
  12. nombremeses=['ENERO','FEBRERO','MARZO','ABRIL','MAYO','JUNIO','JULIO','AGOSTO','SEPTIEMBRE','OCTUBRE','NOVIEMBRE','DICIEMBRE']
  13.  
  14. print(anyo)
  15.  
  16. for mes in range(1,13):
  17.     cad=""
  18.     print("\n     "+nombremeses[mes-1])
  19.     for i in range(1,k):
  20.         cad+="   "
  21.     for i in range(1,diasmeses[mes-1]+1):
  22.         if i<10: cad+=" "+str(i)+" "
  23.         else: cad+=str(i)+" "
  24.         if k%7==0:
  25.             cad+="\n"
  26.             k=0
  27.         k+=1
  28.     print(cad)
  29.    
  30. input("\n Pulsa INTRO para salir")
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement