0% found this document useful (0 votes)
15 views4 pages

C Concours Blanc Spe

Uploaded by

Anowar Saleine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views4 pages

C Concours Blanc Spe

Uploaded by

Anowar Saleine
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 4

#Exercice 01

#Q1
(a,b)=(1,0)
#Q2
def heun(f, t0,T,y0,N) :
h=(T-t0)/N
T=[t0]*N
y=[y0]*N
for i in range(0,N-1,1):
y[i+1]=y[i]+h/2*(f(y[i],T[i])+f(y[i]+h*f(y[i],T[i]),T[i]+h))
T[i+1]=T[i]+h
return y
#Q3
on pose z=(u,u')
 z'=(u',u'')==>z'=(u',-u'-u-cos(2*pi*t))
z'=(z[1],-z[1]-z[0]-cos(2*pi*t))
z'(t)=F(z(t),t)
#Q4
from pylab import *
from scipy.integrate import odeint
def f(z,t):
return array((z[1],-z[1]-z[0]-cos(2*pi*t)))
N=1000
t0=0
T=3
z0=array((0,0))
TT=linspace(t0,T,N)
z=odeint(f,z0,TT)
u=[e[0] for e in z]
plot(TT,u,label="odeint")
z=heun(f,t0,T,z0,N)
u=[e[0] for e in z]
plot(TT,u,label="heun")
xlabel('temps (s)')
ylabel('tension (mV)')
title("circuit RLC, tension bobine")
legend()
show()
#Exercice 02 :
#Q5
from scipy.integrate import trapz
from numpy import linspace
def Imoy(mesure):
s=0
n=len(mesure)
tf=(n-1)*2
t=linspace(0,tf,n)
return trapz(mesure,t)/tf
#Q6
from math import sqrt
def Iec(mesure):
L=[(x-Imoy(mesure))**2 for x in mesure]
return sqrt(Imoy(L))

#Q7

ΠnSerie ( Imoy>Imin et Imoy<Imax (testfin))

#Q8
select nSerie,Iec,fichierMes from testfin where Iec<(SELECT AVG(Iec) from testfin)
#Q9-a
from sqlite3 import *
def afficher(bd,req):
c=connect(bd)
cur=c.cursor()
res=cur.execute(req)
for ligne in list(res):
print(ligne)
c.close()
afficher("C ://TestsImpr.sqlite","select * from production")
#Q9-b
def enregistrer(bd,req,fich):
c=connect(bd)
cur=c.cursor()
res=cur.execute(req)
f=open(fich,"w")
for ligne in list(res):
f.write(str((ligne))+"\n")
f.close()
c.close()
enregistrer("C ://TestsImpr.sqlite","select * from production","fichier.txt")

#Exercice 03(tri par tas(tri maximier))


#Q10-a
def gauche ( i ) :
return 2*i+1
#Q10-b
def droite(i):
return 2*i+2
#Q10-c
def pere(i):
return (i-1)//2
#Q11-a
def maximum(T,i,limite):
imax=i
g=gauche(i)
d=droite(i)
if g<limite and T[imax]<T[g]:
imax=g
if d<limite and T[imax]<T[d]:
imax=d
return imax

#Q11-b
def entasser(T,i,limite ):
imax=maximum(T,i,limite)
if imax!=i:
T[i],T[imax]=T[imax],T[i]
entasser(T,imax,limite)
#Q11-c
def construireTas(T):
for i in range(len(T)//2-1,-1,-1):
entasser(T,i,len(T))
#Q11-d
def estunTas(T) :
for i in range(1,len(T)):
if T[i]>T[pere(i)]:
return False
return True
#Q11-e
def trierTas(T):
for i in range(len(T)-1,0,-1):
T[i],T[0]=T[0],T[i]
entasser(T,0,i)
#Q11-f
def triParTas(T ):
if estunTas(T)==False:
construireTas(T)
trierTas(T)

You might also like