# Cordoba $ \frac{\partial c_{ix}}{\partial x}$

In [144]:
import numpy as np
import pandas as pd
import math
import cmath
from scipy.optimize import root
import matplotlib.pyplot as plt
%matplotlib inline

In [4]:
print("Hola")


Hola

In [5]:
3/5


Out[5]:
0.6

In [6]:
8e-10


Out[6]:
8e-10

In [7]:
x=800

In [8]:
print("Agnès"*30)


AgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnèsAgnès

In [9]:
g = "Universidad"

In [10]:
g+"Nacional"


Out[10]:
'UniversidadNacional'

In [11]:
[1,2,3,4,5,6,7,8,9,10,10,11,12]


Out[11]:
[1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12]

In [12]:
Lista1 = [1,2,3,4,5,6,7,8,9,10,10,11,12]

In [13]:
Lista1[0]


Out[13]:
1

In [14]:
Lista1[-1]


Out[14]:
12

In [15]:
Lista1[2:]


Out[15]:
[3, 4, 5, 6, 7, 8, 9, 10, 10, 11, 12]

In [16]:
Lista1[3:8]


Out[16]:
[4, 5, 6, 7, 8]

In [17]:
matrice1 = np.array([3,10,25,98])
matrice1


Out[17]:
array([ 3, 10, 25, 98])

In [18]:
matrice2 = np.array([[2,9,7],[14,9,22]])
matrice2


Out[18]:
array([[ 2,  9,  7],
       [14,  9, 22]])

In [19]:
matrice2[1][2]


Out[19]:
22

In [20]:
matrice2[0]


Out[20]:
array([2, 9, 7])

In [21]:
matrice2[0][0]


Out[21]:
2

In [22]:
matrice2[0][1]


Out[22]:
9

In [23]:
if matrice2[0][1] > 3: 
    print("Superior")
else: 
    print("Inferior")


Superior

In [24]:
if matrice2[0][1] > 3:
    print("Superior")
elif matrice2[2][1] < 5:
    print("Ok")
else:
    pass


Superior

In [25]:
if matrice2[0][1] < 3:
    print("Superior")
elif matrice2[1][2] > 5:
    print("Ok")
else:
    print("Non")


Ok

In [26]:
if matrice2[0][1] > 3 and matrice2[1][2] > 5: 
    print("Ok")


Ok

In [27]:
def sumar(x,y):
    z = x+y
    return z

In [28]:
sumar(5,4)


Out[28]:
9

In [29]:
sumar("Python","Anaconda")


Out[29]:
'PythonAnaconda'

In [30]:
resultado = sumar(4,5)

In [31]:
resultado*10


Out[31]:
90

In [32]:
def calcular(numero1,numero2,operacion):
    
    if operacion == "+":
        numero3 = numero1 + numero2 
    elif operacion == "-":
        numero3 = numero1 - numero2
    return numero3

In [33]:
calcular(1,2,"+")


Out[33]:
3

In [34]:
calcular(1,2,"-")


Out[34]:
-1

In [35]:
def calcular2(numero1,numero2,operacion):
    
    if operacion == "+":
        numero3 = numero1 + numero2 
        return numero3
    elif operacion == "-":
        numero3 = numero1 - numero2 
        return numero3

In [36]:
calcular2(2,5,"-")


Out[36]:
-3

In [37]:
def multiplicar(numero1,numero2):
    numero3 = numero1*numero2
    return numero3
def cuadrado(numero1):
    numero2 = numero1 **4
    return numero2

In [38]:
operacion = cuadrado(multiplicar(13,25))

In [39]:
operacion


Out[39]:
11156640625

In [40]:
elementos = np.array(["numero","palabras",3,2])

In [41]:
for elemento in elementos: 
    print(elemento)


numero
palabras
3
2

In [42]:
a = np.linspace(2.0,10.0, num =20)
a


Out[42]:
array([ 2.        ,  2.42105263,  2.84210526,  3.26315789,  3.68421053,
        4.10526316,  4.52631579,  4.94736842,  5.36842105,  5.78947368,
        6.21052632,  6.63157895,  7.05263158,  7.47368421,  7.89473684,
        8.31578947,  8.73684211,  9.15789474,  9.57894737, 10.        ])

In [43]:
b = a**4

In [44]:
plt.plot(a,b)
plt.title("Fonction")
plt.xlabel("a")
plt.ylabel("b")
plt.grid(True)



In [45]:
datos = np.random.randn(6,4)
print (datos)
compuestos = ["ethanol","propanol","butanol","butanone","isobutanol","ethylmethylcetone"]
propriedad = ["viscosida","densidad","pression saturante","conductividad"]


[[ 0.34697971 -0.1581298  -0.69601682  0.67452588]
 [ 0.22545314  0.42307345  2.23727046  0.55404901]
 [ 0.07742001  0.01562646 -0.30559832  1.17953383]
 [ 1.14657031 -0.75133242 -0.81239563  1.53757511]
 [ 0.17657201  0.36398444  0.14788283 -0.29438835]
 [-2.51890459  0.49594061 -0.28563097 -0.91089153]]

In [46]:
tabla_de_datos = pd.DataFrame(data=datos,index= compuestos, columns=propriedad)
tabla_de_datos


Out[46]:
viscosida densidad pression saturante conductividad
ethanol 0.346980 -0.158130 -0.696017 0.674526
propanol 0.225453 0.423073 2.237270 0.554049
butanol 0.077420 0.015626 -0.305598 1.179534
butanone 1.146570 -0.751332 -0.812396 1.537575
isobutanol 0.176572 0.363984 0.147883 -0.294388
ethylmethylcetone -2.518905 0.495941 -0.285631 -0.910892

In [47]:
tabla_de_datos["viscosida"]


Out[47]:
ethanol              0.346980
propanol             0.225453
butanol              0.077420
butanone             1.146570
isobutanol           0.176572
ethylmethylcetone   -2.518905
Name: viscosida, dtype: float64

In [48]:
tabla_de_datos.describe()


Out[48]:
viscosida densidad pression saturante conductividad
count 6.000000 6.000000 6.000000 6.000000
mean -0.090985 0.064860 0.047585 0.456734
std 1.250458 0.473696 1.125439 0.914565
min -2.518905 -0.751332 -0.812396 -0.910892
25% 0.102208 -0.114691 -0.598412 -0.082279
50% 0.201013 0.189805 -0.295615 0.614287
75% 0.316598 0.408301 0.039504 1.053282
max 1.146570 0.495941 2.237270 1.537575

In [49]:
tabla_de_datos.values


Out[49]:
array([[ 0.34697971, -0.1581298 , -0.69601682,  0.67452588],
       [ 0.22545314,  0.42307345,  2.23727046,  0.55404901],
       [ 0.07742001,  0.01562646, -0.30559832,  1.17953383],
       [ 1.14657031, -0.75133242, -0.81239563,  1.53757511],
       [ 0.17657201,  0.36398444,  0.14788283, -0.29438835],
       [-2.51890459,  0.49594061, -0.28563097, -0.91089153]])

In [50]:
tabla_de_datos[0:3]


Out[50]:
viscosida densidad pression saturante conductividad
ethanol 0.346980 -0.158130 -0.696017 0.674526
propanol 0.225453 0.423073 2.237270 0.554049
butanol 0.077420 0.015626 -0.305598 1.179534

In [365]:
tabla_de_datos2 = tabla_de_datos.copy()
coefficients = tabla_de_datos2.values
coefficients


Out[365]:
array([[ 0.34697971, -0.1581298 , -0.69601682,  0.67452588],
       [ 0.22545314,  0.42307345,  2.23727046,  0.55404901],
       [ 0.07742001,  0.01562646, -0.30559832,  1.17953383],
       [ 1.14657031, -0.75133242, -0.81239563,  1.53757511],
       [ 0.17657201,  0.36398444,  0.14788283, -0.29438835],
       [-2.51890459,  0.49594061, -0.28563097, -0.91089153]])

In [380]:
coefficients[:,0]


Out[380]:
array([ 0.34697971,  0.22545314,  0.07742001,  1.14657031,  0.17657201,
       -2.51890459])

In [52]:
tabla_de_datos2[tabla_de_datos2 >0]=-tabla_de_datos2
tabla_de_datos2


Out[52]:
viscosida densidad pression saturante conductividad
ethanol -0.346980 -0.158130 -0.696017 -0.674526
propanol -0.225453 -0.423073 -2.237270 -0.554049
butanol -0.077420 -0.015626 -0.305598 -1.179534
butanone -1.146570 -0.751332 -0.812396 -1.537575
isobutanol -0.176572 -0.363984 -0.147883 -0.294388
ethylmethylcetone -2.518905 -0.495941 -0.285631 -0.910892

In [53]:
tabla_de_datos


Out[53]:
viscosida densidad pression saturante conductividad
ethanol 0.346980 -0.158130 -0.696017 0.674526
propanol 0.225453 0.423073 2.237270 0.554049
butanol 0.077420 0.015626 -0.305598 1.179534
butanone 1.146570 -0.751332 -0.812396 1.537575
isobutanol 0.176572 0.363984 0.147883 -0.294388
ethylmethylcetone -2.518905 0.495941 -0.285631 -0.910892

Difusion

Proceso de migracion


In [54]:
tabla_de_temperaturas : [10,20,30,40,50,60,70,80,90,100]

In [55]:
Volume = (7*(2+6+1))
Volume


Out[55]:
63

In [56]:
def Volume(a,b,c,d,e,f,g,h,i,j,k,l):
    z = ((7*(a+b+c+d+e+f))+31.5*g+24.5*h+10.5*i+38.5*j+(21*k-l))
    return z

In [57]:
Volume(2,6,1,0,0,0,0,0,0,0,0,0)


Out[57]:
63.0

In [58]:
def D(phi,PM,T,u,Volume):
    x = 1.173e-16*((phi*PM)**0.5)*(T/(u*Volume**0.6))
    return x

In [59]:
T1 = np.linspace(10,100,10)
T1


Out[59]:
array([ 10.,  20.,  30.,  40.,  50.,  60.,  70.,  80.,  90., 100.])

In [60]:
u = 0.0012

In [61]:
phi = 1.5

In [62]:
PM = 0.0446

In [63]:
D(1.5,0.0446,T1,0.0012,63)


Out[63]:
array([2.10487105e-14, 4.20974210e-14, 6.31461315e-14, 8.41948421e-14,
       1.05243553e-13, 1.26292263e-13, 1.47340974e-13, 1.68389684e-13,
       1.89438395e-13, 2.10487105e-13])

In [64]:
D(1.5,0.0446,20,0.0012,63)


Out[64]:
4.2097421031825687e-14

In [65]:
D(1.5,0.0446,30,0.0012,63)


Out[65]:
6.314613154773852e-14

In [66]:
D(1.5,0.0446,40,0.0012,63)


Out[66]:
8.419484206365137e-14

In [67]:
D(1.5,0.0446,50,0.0012,63)


Out[67]:
1.0524355257956421e-13

In [68]:
D(1.5,0.0446,60,0.0012,63)


Out[68]:
1.2629226309547705e-13

In [69]:
D(1.5,0.0446,70,0.0012,63)


Out[69]:
1.473409736113899e-13

In [70]:
D(1.5,0.0446,80,0.0012,63)


Out[70]:
1.6838968412730275e-13

In [71]:
Diffusion3 = [2.10487105e-14, 4.20974210e-14, 6.31461315e-14, 8.41948421e-14,1.05243553e-13, 1.26292263e-13, 1.47340974e-13, 1.68389684e-13,1.89438395e-13, 2.10487105e-13]
Diffusion3


Out[71]:
[2.10487105e-14,
 4.2097421e-14,
 6.31461315e-14,
 8.41948421e-14,
 1.05243553e-13,
 1.26292263e-13,
 1.47340974e-13,
 1.68389684e-13,
 1.89438395e-13,
 2.10487105e-13]

In [72]:
plt.plot(T1,Diffusion3)
plt.title("Diffusion = f(T)")
plt.xlabel("Température en degré")
plt.ylabel("Diffusion")


Out[72]:
Text(0,0.5,'Diffusion')

In [ ]:


In [73]:
Dif = ["Diffusion"]

In [74]:
tabla_de_diffusion = pd.DataFrame(data=Diffusion3,index=T1,columns = Dif)
tabla_de_diffusion


Out[74]:
Diffusion
10.0 2.104871e-14
20.0 4.209742e-14
30.0 6.314613e-14
40.0 8.419484e-14
50.0 1.052436e-13
60.0 1.262923e-13
70.0 1.473410e-13
80.0 1.683897e-13
90.0 1.894384e-13
100.0 2.104871e-13

In [75]:
tabla_de_diffusion.describe()


Out[75]:
Diffusion
count 1.000000e+01
mean 1.157679e-13
std 6.372814e-14
min 2.104871e-14
25% 6.840831e-14
50% 1.157679e-13
75% 1.631275e-13
max 2.104871e-13

In [76]:
T = np.linspace(273,400,10)
T


Out[76]:
array([273.        , 287.11111111, 301.22222222, 315.33333333,
       329.44444444, 343.55555556, 357.66666667, 371.77777778,
       385.88888889, 400.        ])

Viscosité


In [77]:
def Viscosite(A,B,C,T):
    v = np.exp(A+(B/(C+T)))
    return v

In [78]:
Viscosite(-7.37146,2770.25,74.6787,T)


Out[78]:
array([1.81554378, 1.33057377, 0.99816978, 0.76454528, 0.59660798,
       0.47341651, 0.38137704, 0.31145891, 0.25753515, 0.215368  ])

In [79]:
Viscosité = [1.80931608, 1.0559807 , 0.65980795, 0.43602046, 0.30187114,0.21733649, 0.16175719, 0.12386075, 0.09719506, 0.07791022]
Viscosité


Out[79]:
[1.80931608,
 1.0559807,
 0.65980795,
 0.43602046,
 0.30187114,
 0.21733649,
 0.16175719,
 0.12386075,
 0.09719506,
 0.07791022]

In [80]:
plt.plot(T,Viscosité)
plt.title("Viscosité = f(T)")
plt.xlabel("Température en k")
plt.ylabel("Viscosité")


Out[80]:
Text(0,0.5,'Viscosité')

In [81]:
T3 = np.linspace(273,400,5)
T3


Out[81]:
array([273.  , 304.75, 336.5 , 368.25, 400.  ])

In [82]:
Viscosite(-7.37146,2770.25,74.6787,T3)


Out[82]:
array([1.81554378, 0.93206588, 0.53040113, 0.32723806, 0.215368  ])

In [83]:
T4 = np.linspace(0,127,5)
T4


Out[83]:
array([  0.  ,  31.75,  63.5 ,  95.25, 127.  ])

In [84]:
D(1.5,0.0446,T4,0.0012,63)


Out[84]:
array([0.00000000e+00, 6.68296559e-14, 1.33659312e-13, 2.00488968e-13,
       2.67318624e-13])

In [85]:
Vis1 = ["Viscosité"]

In [86]:
tabla_de_viscosité = pd.DataFrame(data=Viscosité,index=T, columns= Vis1)
tabla_de_viscosité


Out[86]:
Viscosité
273.000000 1.809316
287.111111 1.055981
301.222222 0.659808
315.333333 0.436020
329.444444 0.301871
343.555556 0.217336
357.666667 0.161757
371.777778 0.123861
385.888889 0.097195
400.000000 0.077910

In [87]:
tabla_de_viscosité.describe()


Out[87]:
Viscosité
count 10.000000
mean 0.494106
std 0.554593
min 0.077910
25% 0.133335
50% 0.259604
75% 0.603861
max 1.809316

In [88]:
tabla_de_viscosité.mean()


Out[88]:
Viscosité    0.494106
dtype: float64

In [89]:
tabla_de_diffusion.mean()


Out[89]:
Diffusion    1.157679e-13
dtype: float64

Diffusion/Viscosité

Diffusion et viscosité en fonction de T (5 températures)


In [90]:
Viscosité [2:7]


Out[90]:
[0.65980795, 0.43602046, 0.30187114, 0.21733649, 0.16175719]

In [91]:
Diffusion3 [2:7]


Out[91]:
[6.31461315e-14,
 8.41948421e-14,
 1.05243553e-13,
 1.26292263e-13,
 1.47340974e-13]

In [92]:
T4 = [10,20,30,40,50]

In [93]:
plt.plot(T4,Viscosité[2:7])
plt.plot(T4,Diffusion3[2:7])
plt.title("Diffusivité et viscosité en fonction de T")
plt.xlabel("Température")


Out[93]:
Text(0.5,0,'Température')

In [94]:
Diffusion3[2:7]


Out[94]:
[6.31461315e-14,
 8.41948421e-14,
 1.05243553e-13,
 1.26292263e-13,
 1.47340974e-13]

In [95]:
tabla1 = pd.DataFrame(data = T4, index = Diffusion3[2:7])
tabla1


Out[95]:
0
6.314613e-14 10
8.419484e-14 20
1.052436e-13 30
1.262923e-13 40
1.473410e-13 50

In [96]:
tabla2 = pd.DataFrame(data =T4, index =Viscosité[2:7])
tabla2


Out[96]:
0
0.659808 10
0.436020 20
0.301871 30
0.217336 40
0.161757 50

In [97]:
tabla_de_viscosité2 = tabla_de_viscosité.copy()
tabla_de_viscosité2


Out[97]:
Viscosité
273.000000 1.809316
287.111111 1.055981
301.222222 0.659808
315.333333 0.436020
329.444444 0.301871
343.555556 0.217336
357.666667 0.161757
371.777778 0.123861
385.888889 0.097195
400.000000 0.077910

In [98]:
tabla_de_viscosité2[tabla_de_viscosité2 >0.494106]


Out[98]:
Viscosité
273.000000 1.809316
287.111111 1.055981
301.222222 0.659808
315.333333 NaN
329.444444 NaN
343.555556 NaN
357.666667 NaN
371.777778 NaN
385.888889 NaN
400.000000 NaN

In [99]:
tabla_de_diffusion2 =tabla_de_diffusion.copy()
tabla_de_diffusion2


Out[99]:
Diffusion
10.0 2.104871e-14
20.0 4.209742e-14
30.0 6.314613e-14
40.0 8.419484e-14
50.0 1.052436e-13
60.0 1.262923e-13
70.0 1.473410e-13
80.0 1.683897e-13
90.0 1.894384e-13
100.0 2.104871e-13

In [100]:
tabla_de_diffusion2[tabla_de_diffusion2>1.157679e-13]


Out[100]:
Diffusion
10.0 NaN
20.0 NaN
30.0 NaN
40.0 NaN
50.0 NaN
60.0 1.262923e-13
70.0 1.473410e-13
80.0 1.683897e-13
90.0 1.894384e-13
100.0 2.104871e-13

Fonction Dictionnaire


In [101]:
print("Hoy estoy en la universidad nacional de cordoba")


Hoy estoy en la universidad nacional de cordoba

In [102]:
Universidad1 = "universidad nacional de Cordoba"

In [103]:
Universidad2 = "Institut Universitaire Paul Sabatier"

In [104]:
print("Hoy estoy en la",Universidad)


---------------------------------------------------------------------------
NameError                                 Traceback (most recent call last)
<ipython-input-104-a7e298498b44> in <module>()
----> 1 print("Hoy estoy en la",Universidad)

NameError: name 'Universidad' is not defined

In [ ]:
print("Antes estaba en el {1} y Hoy estoy en la {0}".format(Universidad1,Universidad2))

In [ ]:
C = 1.4e-4

In [ ]:
print("La concentration de éthanol es de",C)

In [ ]:
print("La concentration d'éthanol est {0}".format(C))

In [ ]:
Densidades = {"ethanol":1.8,"propanol":2.6,"isobutanol":3.4,"methylethylcetone":4.2}
Densidades

In [ ]:
Densidades ["propanol"]

In [ ]:
Densidades.keys()

In [ ]:
Densidades.items()

In [ ]:
for (sustancia,densidad) in Densidades.items():
    print("La densidad de {0} es igual a {1}".format(sustancia,densidad))

In [ ]:
Comidades = ["Citron","Chocolat","Pitaya","Muesli","Noix de coco"]
Precios =[2,1,4,5,8]

In [ ]:
zip(Comidades,Precios)

In [ ]:
dict(zip(Comidades,Precios))

In [ ]:
plt.plot(Comidades,Precios)
plt.annotate(s = "me gusta",xy=(2,5))

Polynôme 8x²-4x+3 = 0


In [ ]:
a = 8
b = -4
c = 3
D = b**2-4*a*c
x1 = (-b+ D**0.5)/(2*a)
print(x1)
x2 = (-b-D**0.5)/2*a
print(x2)

In [ ]:
str(5)

In [ ]:
int("5")

In [ ]:
int("Cinco")

In [ ]:
valor = int (input("ingresar un numero"))

In [ ]:
valor

In [ ]:
valor

In [ ]:
int(valor)

In [ ]:
while True:
    try:
        x = int(input("Ingresar un numero"))
        print("Correct")
        break 
    except ValueError:
        print("Incorrect")

In [ ]:
i = 0
while True: 
    print(i)
    if i >= 10: 
        break
    i = i+1

ax²+bx+c =0


In [ ]:


In [ ]:
a = int(input("ingresar un numero"))
b = int(input("ingresar un numero"))
c = int(input("ingresar un numero"))
D = b**2-(4*a*c)
print("D =",D)
if D < 0:
    print ("Pas de solutions reelles")
elif D == 0:
    x = (-b+math.sqrt(b**2-4*a*c))/2*a
    print ("L'equation a une solution: x = ", x)
else:
    x1 = (-b+math.sqrt(b**2-4*a*c))/2*a
    x2 = (-b-math.sqrt(b**2-4*a*c))/2*a
    print ("L'equation a deux solution: x1 = ", x1, " et x2 =", x2)

In [ ]:
while True:
    try:
        d = 1/D     
        print("Possible")
        break 
    except ZeroDivisionError:
        print("Division par 0 : impossible") 
        break

In [ ]:
if D < 0:
    print("D=",D)
    x1 = (-b+cmath.sqrt(b**2-4*a*c))/2*a
    x2 = (-b-cmath.sqrt(b**2-4*a*c))/2*a
    print ("L'equation a deux solution: x1 = ", x1, " et x2 =", x2)

In [ ]:
def cuadratica(a,b,c):
    a = int(input("ingresar un numero"))
    b = int(input("ingresar un numero"))
    c = int(input("ingresar un numero"))
    Delta = (b**2)-(4*a*c)
    print ("Delta = {}".format(Delta))
    if Delta < 0:
        print ("Pas de solutions reelles")
    elif Delta == 0:
        x = (-b+math.sqrt(b**2-4*a*c))/2*a
        print ("L'equation a une solution: x = {}".format(x))
    else:
        x1 = (-b+math.sqrt(b**2-4*a*c))/2*a
        x2 = (-b-math.sqrt(b**2-4*a*c))/2*a
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    try:
        d = 1/Delta     
        print("Possible") 
    except ZeroDivisionError:
        print("Division par 0 : impossible")

In [ ]:
cuadratica(3,5,1)

In [ ]:
cuadratica(1,2,3)

In [ ]:
def cuadratica(a,b,c):
    a = int(input("ingresar un numero"))
    b = int(input("ingresar un numero"))
    c = int(input("ingresar un numero"))
    Delta = (b**2)-(4*a*c)
    print ("Delta = {}".format(Delta))
    if Delta < 0:
        x1 = (-b+cmath.sqrt(b**2-4*a*c))/2*a
        x2 = (-b-cmath.sqrt(b**2-4*a*c))/2*a
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    elif Delta == 0:
        x = (-b+math.sqrt(b**2-4*a*c))/2*a
        print ("L'equation a une solution: x = {}".format(x))
    else:
        x1 = (-b+math.sqrt(b**2-4*a*c))/2*a
        x2 = (-b-math.sqrt(b**2-4*a*c))/2*a
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    try:
        d = 1/Delta     
        print("Possible") 
    except ZeroDivisionError:
        print("Division par 0 : impossible") 
x = np.linspace(-10,10,100)
y = a*x**2+b*x+c
plt.plot(x,y)
plt.title("Fonction")
plt.xlabel("x")
plt.ylabel("y")
plt.grid(True)

In [ ]:
cuadratica(1,2,5)

In [125]:
def cuadratica(a,b,c):
    """ Esta function resuelve una equation cuadratrica  
    De la forma ax²+bx+c""" 
    a = int(input("ingresar un numero"))
    b = int(input("ingresar un numero"))
    c = int(input("ingresar un numero"))
    Delta = (b**2)-(4*a*c)
    print ("Delta = {}".format(Delta))
    if Delta < 0:
        print("L'equation n'a pas de solutions réelles")
        x1 = (-b+cmath.sqrt((b**2)-(4*a*c)))/(2*a)
        x2 = (-b-cmath.sqrt((b**2)-(4*a*c)))/(2*a)
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    elif Delta == 0:
        x = (-b/(2*a))
        print ("L'equation a une solution: x = {}".format(x))
    else:
        x1 = (-b+math.sqrt((b**2)-(4*a*c)))/(2*a)
        x2 = (-b-math.sqrt((b**2)-(4*a*c)))/(2*a)
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    try:
        d = 1/Delta     
        print("Possible") 
    except ZeroDivisionError:
        print("Division par 0 : impossible") 
    x = np.linspace(-5,5,100)
    g = (a*x**2)+b*x+c        
    plt.plot(x,g)
    plt.title("Fonction")
    plt.xlabel("x")
    plt.ylabel("y")
    plt.grid(True)
    plt.annotate("x1",xy=(x1,0))
    plt.annotate("x2",xy=(x2,0))

In [126]:
cuadratica.__doc__


Out[126]:
' Esta function resuelve una equation cuadratrica  \n    De la forma ax²+bx+c'

In [118]:
cuadratica(1,2,3)


ingresar un numero2
ingresar un numero4
ingresar un numero-4
Delta = 48
L'equation a deux solution: x1 = 0.7320508075688772 et x2 =-2.732050807568877
Possible

In [111]:
cuadratica(1,2,3)


ingresar un numero4
ingresar un numero6
ingresar un numero-2
Delta = 68
L'equation a deux solution: x1 = 0.28077640640441515 et x2 =-1.7807764064044151
Possible

In [134]:
dataset=pd.read_csv("Texet1.txt",sep=" ")
dataset


Out[134]:
Je m'appelle Agnès
0 1 2 3
1 4 5 6
2 7 8 9

In [137]:
dataset["Agnès"]


Out[137]:
0    3
1    6
2    9
Name: Agnès, dtype: int64

In [143]:
dataset=pd.read_csv("Table1.txt",sep=" ")
dataset


Out[143]:
Experiment Thickness Food Simulant Cpo K Dp RMSE
0 1 146 EtOH95% 1157(+/-112) 52 1.950000e-13 1.5 NaN

In [152]:
def fonction(x,a,b,c):
    return a*x**2+b*x+c

In [157]:
a = 5
b = 2
c = 4
sol = root(fonction,32.8,args=(a,b,c))
sol.x


Out[157]:
array([-0.19979919])

Flux de Transfert


In [265]:
def fonction1(c2,D,L,c1,c4,K,k): 
    j1 = (D/(L/2)*(c1-c2))
    c3 = c2/K
    j2 = k*(c3-c4)
    return (j1-j2)/j1

In [266]:
D = 1.93e-13
L = 146e-6
c1 = 1157
c4 = 0.5
K = 52
k = 7.14e-6
sol = root(fonction1,24,args=(D,L,c1,c4,K,k))
sol.x


Out[266]:
array([47.36581234])

In [ ]:


In [172]:
c1 = np.linspace(1157-112,1157+112,100)
c1


Out[172]:
array([1045.        , 1047.26262626, 1049.52525253, 1051.78787879,
       1054.05050505, 1056.31313131, 1058.57575758, 1060.83838384,
       1063.1010101 , 1065.36363636, 1067.62626263, 1069.88888889,
       1072.15151515, 1074.41414141, 1076.67676768, 1078.93939394,
       1081.2020202 , 1083.46464646, 1085.72727273, 1087.98989899,
       1090.25252525, 1092.51515152, 1094.77777778, 1097.04040404,
       1099.3030303 , 1101.56565657, 1103.82828283, 1106.09090909,
       1108.35353535, 1110.61616162, 1112.87878788, 1115.14141414,
       1117.4040404 , 1119.66666667, 1121.92929293, 1124.19191919,
       1126.45454545, 1128.71717172, 1130.97979798, 1133.24242424,
       1135.50505051, 1137.76767677, 1140.03030303, 1142.29292929,
       1144.55555556, 1146.81818182, 1149.08080808, 1151.34343434,
       1153.60606061, 1155.86868687, 1158.13131313, 1160.39393939,
       1162.65656566, 1164.91919192, 1167.18181818, 1169.44444444,
       1171.70707071, 1173.96969697, 1176.23232323, 1178.49494949,
       1180.75757576, 1183.02020202, 1185.28282828, 1187.54545455,
       1189.80808081, 1192.07070707, 1194.33333333, 1196.5959596 ,
       1198.85858586, 1201.12121212, 1203.38383838, 1205.64646465,
       1207.90909091, 1210.17171717, 1212.43434343, 1214.6969697 ,
       1216.95959596, 1219.22222222, 1221.48484848, 1223.74747475,
       1226.01010101, 1228.27272727, 1230.53535354, 1232.7979798 ,
       1235.06060606, 1237.32323232, 1239.58585859, 1241.84848485,
       1244.11111111, 1246.37373737, 1248.63636364, 1250.8989899 ,
       1253.16161616, 1255.42424242, 1257.68686869, 1259.94949495,
       1262.21212121, 1264.47474747, 1266.73737374, 1269.        ])

In [175]:
Longitud = len(c1)
Longitud


Out[175]:
100

In [176]:
c2 = np.zeros(100)
c2


Out[176]:
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])

In [177]:
c2[4]=5
c2


Out[177]:
array([0., 0., 0., 0., 5., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.,
       0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0., 0.])

In [268]:
D = 1.93e-13
L = 146e-6
c1 = np.linspace(1157-112,1157+112,100)
c4 = 0.5
K = 52
k = 7.14e-6
sol = root(fonction1,15,args=(D,L,c1,c4,K,k))
sol


Out[268]:
    fjac: array([[-1.]])
     fun: array([0.        , 1.55343026, 1.55221984, 1.55101471, 1.54981483,
       1.54862016, 1.54743067, 1.54624632, 1.54506709, 1.54389295,
       1.54272385, 1.54155976, 1.54040066, 1.5392465 , 1.53809727,
       1.53695293, 1.53581344, 1.53467878, 1.53354891, 1.53242381,
       1.53130345, 1.53018779, 1.5290768 , 1.52797046, 1.52686874,
       1.52577161, 1.52467903, 1.52359099, 1.52250745, 1.52142839,
       1.52035378, 1.51928358, 1.51821778, 1.51715634, 1.51609925,
       1.51504646, 1.51399796, 1.51295373, 1.51191372, 1.51087793,
       1.50984632, 1.50881886, 1.50779554, 1.50677633, 1.5057612 ,
       1.50475013, 1.50374309, 1.50274007, 1.50174103, 1.50074595,
       1.49975481, 1.49876759, 1.49778426, 1.4968048 , 1.49582919,
       1.4948574 , 1.49388941, 1.4929252 , 1.49196475, 1.49100804,
       1.49005504, 1.48910573, 1.48816009, 1.4872181 , 1.48627974,
       1.48534499, 1.48441383, 1.48348623, 1.48256217, 1.48164165,
       1.48072462, 1.47981109, 1.47890101, 1.47799439, 1.47709119,
       1.47619139, 1.47529499, 1.47440195, 1.47351226, 1.47262591,
       1.47174286, 1.47086311, 1.46998664, 1.46911342, 1.46824344,
       1.46737668, 1.46651312, 1.46565275, 1.46479555, 1.4639415 ,
       1.46309057, 1.46224277, 1.46139806, 1.46055644, 1.45971788,
       1.45888237, 1.45804989, 1.45722042, 1.45639396, 1.45557047])
 message: 'The solution converged.'
    nfev: 7
     qtf: array([3.71892757e-11])
       r: array([0.05294827])
  status: 1
 success: True
       x: array([45.25001129])

In [193]:
c2 = [1.5535421        , 1.55343026, 1.55221984, 1.55101471, 1.54981483,
       1.54862016, 1.54743067, 1.54624632, 1.54506709, 1.54389295,
       1.54272385, 1.54155976, 1.54040066, 1.5392465 , 1.53809727,
       1.53695293, 1.53581344, 1.53467878, 1.53354891, 1.53242381,
       1.53130345, 1.53018779, 1.5290768 , 1.52797046, 1.52686874,
       1.52577161, 1.52467903, 1.52359099, 1.52250745, 1.52142839,
       1.52035378, 1.51928358, 1.51821778, 1.51715634, 1.51609925,
       1.51504646, 1.51399796, 1.51295373, 1.51191372, 1.51087793,
       1.50984632, 1.50881886, 1.50779554, 1.50677633, 1.5057612 ,
       1.50475013, 1.50374309, 1.50274007, 1.50174103, 1.50074595,
       1.49975481, 1.49876759, 1.49778426, 1.4968048 , 1.49582919,
       1.4948574 , 1.49388941, 1.4929252 , 1.49196475, 1.49100804,
       1.49005504, 1.48910573, 1.48816009, 1.4872181 , 1.48627974,
       1.48534499, 1.48441383, 1.48348623, 1.48256217, 1.48164165,
       1.48072462, 1.47981109, 1.47890101, 1.47799439, 1.47709119,
       1.47619139, 1.47529499, 1.47440195, 1.47351226, 1.47262591,
       1.47174286, 1.47086311, 1.46998664, 1.46911342, 1.46824344,
       1.46737668, 1.46651312, 1.46565275, 1.46479555, 1.4639415 ,
       1.46309057, 1.46224277, 1.46139806, 1.46055644, 1.45971788,
       1.45888237, 1.45804989, 1.45722042, 1.45639396, 1.45557047]

In [240]:
plt.plot(c1,c2, "b--")
plt.title("c2 = f (c1)")
plt.xlabel("c1")
plt.ylabel("c2")


Out[240]:
Text(0,0.5,'c2')

In [303]:
def fonction2(c2,D,L,c1,c4,K,k): 
    j1 = (D/(L/2)*(c1-c2))
    c3 = c2/K
    j2 = k*(c3-c4)
    return (j1-j2)/j1
i = 0
c2 = np.zeros(100) 
dimension = np.shape(c2)
print(dimension)
c1 = np.linspace(1157-112,1157+112,100)
D = 1.93e-13
L = 146e-6
c4 = 0.05
K = 52
k = 7.14e-6
for c1i in c1:
    sol = root(fonction2,15,args=(D,L,c1i,c4,K,k))
    c2[i]= sol.x 
    i = i + 1
print(c2)


(100,)
[22.29206258 22.33480604 22.37754949 22.42029295 22.46303641 22.50577986
 22.54852332 22.59126677 22.63401023 22.67675368 22.71949714 22.76224059
 22.80498405 22.8477275  22.89047096 22.93321442 22.97595787 23.01870133
 23.06144478 23.10418824 23.14693169 23.18967515 23.2324186  23.27516206
 23.31790551 23.36064897 23.40339243 23.44613588 23.48887934 23.53162279
 23.57436625 23.6171097  23.65985316 23.70259661 23.74534007 23.78808352
 23.83082698 23.87357044 23.91631389 23.95905735 24.0018008  24.04454426
 24.08728771 24.13003117 24.17277462 24.21551808 24.25826153 24.30100499
 24.34374845 24.3864919  24.42923536 24.47197881 24.51472227 24.55746572
 24.60020918 24.64295263 24.68569609 24.72843954 24.771183   24.81392646
 24.85666991 24.89941337 24.94215682 24.98490028 25.02764373 25.07038719
 25.11313064 25.1558741  25.19861755 25.24136101 25.28410447 25.32684792
 25.36959138 25.41233483 25.45507829 25.49782174 25.5405652  25.58330865
 25.62605211 25.66879556 25.71153902 25.75428248 25.79702593 25.83976939
 25.88251284 25.9252563  25.96799975 26.01074321 26.05348666 26.09623012
 26.13897357 26.18171703 26.22446049 26.26720394 26.3099474  26.35269085
 26.39543431 26.43817776 26.48092122 26.52366467]

In [258]:
def fonction2(c2,D,L,c1,c4,K,k): 
    j1 = (D/(L/2)*(c1-c2))
    c3 = c2/K
    j2 = k*(c3-c4)
    return (j1-j2)/j1

In [272]:
D = 1.93e-13
L = 146e-6
c1 = np.linspace(1157-112,1157+112,100)
c4 = 0.05
K = 52
k = 7.14e-6
sol = root(fonction1,15,args=(D,L,c1,c4,K,k))
sol


Out[272]:
    fjac: array([[-1.]])
     fun: array([-3.13266697e-16,  3.76133163e-01,  3.77497631e-01,  3.78856145e-01,
        3.80208742e-01,  3.81555460e-01,  3.82896339e-01,  3.84231417e-01,
        3.85560729e-01,  3.86884315e-01,  3.88202211e-01,  3.89514453e-01,
        3.90821078e-01,  3.92122122e-01,  3.93417620e-01,  3.94707609e-01,
        3.95992122e-01,  3.97271194e-01,  3.98544862e-01,  3.99813157e-01,
        4.01076115e-01,  4.02333768e-01,  4.03586151e-01,  4.04833297e-01,
        4.06075237e-01,  4.07312005e-01,  4.08543633e-01,  4.09770153e-01,
        4.10991597e-01,  4.12207995e-01,  4.13419380e-01,  4.14625782e-01,
        4.15827232e-01,  4.17023760e-01,  4.18215396e-01,  4.19402171e-01,
        4.20584114e-01,  4.21761255e-01,  4.22933622e-01,  4.24101245e-01,
        4.25264152e-01,  4.26422373e-01,  4.27575934e-01,  4.28724865e-01,
        4.29869193e-01,  4.31008946e-01,  4.32144151e-01,  4.33274835e-01,
        4.34401026e-01,  4.35522749e-01,  4.36640032e-01,  4.37752901e-01,
        4.38861381e-01,  4.39965500e-01,  4.41065282e-01,  4.42160753e-01,
        4.43251938e-01,  4.44338863e-01,  4.45421552e-01,  4.46500030e-01,
        4.47574321e-01,  4.48644451e-01,  4.49710442e-01,  4.50772320e-01,
        4.51830107e-01,  4.52883827e-01,  4.53933505e-01,  4.54979162e-01,
        4.56020822e-01,  4.57058508e-01,  4.58092243e-01,  4.59122049e-01,
        4.60147948e-01,  4.61169963e-01,  4.62188116e-01,  4.63202428e-01,
        4.64212922e-01,  4.65219618e-01,  4.66222538e-01,  4.67221704e-01,
        4.68217136e-01,  4.69208855e-01,  4.70196882e-01,  4.71181238e-01,
        4.72161943e-01,  4.73139017e-01,  4.74112480e-01,  4.75082353e-01,
        4.76048655e-01,  4.77011406e-01,  4.77970625e-01,  4.78926332e-01,
        4.79878546e-01,  4.80827286e-01,  4.81772572e-01,  4.82714421e-01,
        4.83652853e-01,  4.84587887e-01,  4.85519540e-01,  4.86447831e-01])
 message: 'The solution converged.'
    nfev: 6
     qtf: array([-9.75518447e-10])
       r: array([0.05175966])
  status: 1
 success: True
       x: array([22.29206258])

In [ ]:


In [304]:
plt.plot(c1,c2, "g--")
plt.title("c2 = f (c1)")
plt.xlabel("c1")
plt.ylabel("c2")


Out[304]:
Text(0,0.5,'c2')

In [354]:
raw_data = {'first_name': ['Jason', 'Molly', 'Tina', 'Jake', 'Amy'], 
        'last_name': ['Miller', 'Jacobson', 'Ali', 'Milner', 'Cooze'], 
        'age': [42, 52, 36, 24, 73], 
        'preTestScore': [4, 24, 31, 2, 3],
        'postTestScore': [25, 94, 57, 62, 70]}
df = pd.DataFrame(raw_data, index = ['exp1', 'exp2', 'exp3','exp4','exp5'],columns = ['first_name', 'last_name', 'age', 'preTestScore', 'postTestScore']
)
df


Out[354]:
first_name last_name age preTestScore postTestScore
exp1 Jason Miller 42 4 25
exp2 Molly Jacobson 52 24 94
exp3 Tina Ali 36 31 57
exp4 Jake Milner 24 2 62
exp5 Amy Cooze 73 3 70

In [355]:
df.to_csv('df2')

In [348]:
df["postTestScore"]


Out[348]:
0    25
1    94
2    57
3    62
4    70
Name: postTestScore, dtype: int64

In [ ]:


In [345]:
class Rectangle:
    def __init__(self,base, altura):
        self.base = base
        self.altura = altura
    def aire(self):
        return self.base*self.altura
    def perimetre(self):
        return(self.base+self.altura)*2
    def volume(self, profondeur):
        return self.aire()*profondeur
    def __str__(self):
        return"{} de {}x{}".format(type(self). name, self.base,self.altura)

In [346]:
r = Rectangle(3,4)
r


Out[346]:
<__main__.Rectangle at 0x2259f150320>

In [343]:
class Polynôme:
    def __init__ (dataset=pd.read_csv("fbao.txt",sep=" ")):
        def calcul(self):
    Delta = (b**2)-(4*a*c)
    print ("Delta = {}".format(Delta))
    if Delta < 0:
        print("L'equation n'a pas de solutions réelles")
        x1 = (-b+cmath.sqrt((b**2)-(4*a*c)))/(2*a)
        x2 = (-b-cmath.sqrt((b**2)-(4*a*c)))/(2*a)
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    elif Delta == 0:
        x = (-b/(2*a))
        print ("L'equation a une solution: x = {}".format(x))
    else:
        x1 = (-b+math.sqrt((b**2)-(4*a*c)))/(2*a)
        x2 = (-b-math.sqrt((b**2)-(4*a*c)))/(2*a)
        print ("L'equation a deux solution: x1 = {0} et x2 ={1}".format(x1,x2))
    try:
        d = 1/Delta     
        print("Possible") 
    except ZeroDivisionError:
        print("Division par 0 : impossible") 
    x = np.linspace(-5,5,100)
    g = (a*x**2)+b*x+c        
    plt.plot(x,g)
    plt.title("Fonction")
    plt.xlabel("x")
    plt.ylabel("y")
    plt.grid(True)
    plt.annotate("x1",xy=(x1,0))
    plt.annotate("x2",xy=(x2,0))
    def garder(self):
        df.to_csv


  File "<ipython-input-343-4323d9e80de8>", line 4
    Delta = (b**2)-(4*a*c)
    ^
IndentationError: expected an indented block

In [ ]: