Contact Us!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutSign UpSign In

Real-time collaboration for Jupyter Notebooks, Linux Terminals, LaTeX, VS Code, R IDE, and more,
all in one place. Commercial Alternative to JupyterHub.

| Download

Jupyter notebook Tiempo real y tiempo aproximado.ipynb

Views: 27
Kernel: SageMath 6.10
#Importamos el paquete datetime import datetime as dt #Usamos la herramienta datetime.now() dt.datetime.now()
#usamos la herramienta datetime.today() today = dt.datetime.today() print today
type(today)
today.weekday() # zero-based numbering; 0 = Monday
#Tales objetos pueden contruirse directamente micumpleanios = dt.datetime(2016, 10, 31)
print micumpleanios.weekday()
str(micumpleanios)
micumpleanios.year
micumpleanios.month
micumpleanios.day
micumpleanios.hour
#Vía el método "toordinal", podemos traducir la fecha a un número ordinal ordinal = micumpleanios.toordinal() ordinal
dt.datetime.fromordinal(ordinal)
show("Tiempo real y tiempo aproximado") enunciado = "¿Cuál será el monto el 24 de diciembre de un capital de $10 000 depositado \n\ el 15 de mayo del mismo año en una cuenta de ahorros que paga 19% anual simple?" show(enunciado)
import datetime as dt final = dt.datetime(2016, 12, 24) print final
inicial = dt.datetime(2016, 5, 15) print inicial
lapso = final-inicial print lapso
dias = lapso.days print dias
T = dias/365 #timepo medido en días (sin usar la convención comercial) Co=10000 #deposito inicial r=0.19 #interés anual simple
#Calculamos el monto final M = Co*(1+r*T) print M
hoy = dt.datetime.today() print hoy cuandonaci = dt.datetime(1984, 10, 31, 4,0,0) print cuandonaci print hoy - cuandonaci (11551/7833).n()
enunciado = "El 11 de julio se firmó un pagaré por $1 700 con 18% de interés. ¿En qué fecha los intereses llegarán a $150?" show(enunciado)
#Usaremos la fórmula I=Co*r*T #Despejando T obtenemos T=I/(Co*r) I=150 Co=1700 r=.18 T=I/(Co*r) print T
from datetime import timedelta print T*365 #round(x,n) redondea con n cifras decimales print round(T*365, 0) #int() convierte un número a entero print int(round(T*365, 0)) tiempoendias = int(round(T*365,0)) # convertimos el tiempo en años a tiempo en días
diferencia = timedelta( days = tiempoendias) print diferencia
fecha = dt.datetime(2016, 7, 11) fecha_final = fecha + diferencia print fecha_final