TD 2 – Fonctions Notions : Encore s`exercer sur les boucles (for et

TD#2#–#Fonctions#
!"#$"%&'('
)%*"+,'&-,.,+*,+'&/+'0,&'1"/*0,&'23"+',#'45$0,67'0,&'$3',#'0,&'0$&#,&'
8 9,&'3"%*#$"%&'
8 9,&'*0:&&,&'21:&$;/,6'
8 <#+/*#/+,+'/%'=+">+:??,'
@"/&'A*+$+,B'C"&'3"%*#$"%&'D,'0:'=+,?$E+,'=:+#$,'D:%&'/%'3$*5$,+'%"??A'FGHI=JI'
K,'3$*5$,+',&#'/%'L'&*+$=#'M'=J#5"%I'
!"/&' C"/&' D,?:%D"%&' ;/-$0&'+,&=,*#,%#' toujours'0-"+>:%$&:#$"%' DA*+$#,' *$8
D,&&"/&'('
8 N%,' =+,?$E+,' 0$>%,' *"%#,%:%#' L'O' 8P8' *"D$%>(' /#38Q' 8P8' M' ="/+' AC$#,+' 0,&'
=+"10E?,&'D-:**,%#&I'
8 R,&' *"??,%#:$+,&' :C:%#' *5:;/,' 3"%*#$"%' DA*+$C:%#' *,' ;/-,00,' 3:$#,' ,#' &,&'
:+>/?,%#&'2#J=,'D,&':+>/?,%#&',#'*,';/,'3:$#'0:'3"%*#$"%6'
8 N%,'3"%*#$"%'main26'S'0:'3$%'D/'&*+$=#';/$':==,00,'0,&':/#+,&'3"%*#$"%&',#';/$'
>+T*,':/'D,+%$,+'if'&,+:':==,0A,'0"+&'D,'0-,.A*/#$"%'D/'&*+$=#I''
-(Pour(que(vos(scripts(restent(clairs(et(lisibles,(il(vous(est(demander(de(ne(
pas(écrire(de(code(python(ailleurs(que(dans(une(fonction.(
!
# -*- coding: utf-8 -*-
# maFonction1: Expliquer ce que fait maFonction1
#ce que sont ses arguments...
def maFonction1(arg1, arg2, arg3):
return arg1+arg2+arg3
#plus(a,b) : fonction retournant la somme de a et b
#a : nombre
#b : nombre
def plus(a,b):
return a+b
#Fonction principale, appelant les autres fonctions
def main() :
print maFonction1(5,6,7)
b=plus(5,6)
print b
#Appel de la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ZI'N%,'C:0,/+'3:$10,'D,'K'
$%D$;/,' ;/,' 0, +A&$D/' ,&#' D:%&' /%,' +A>$"%' =+"#/1A+:%#,' D,' 0:' &/+3:*,' D,' 0:'
=+"#A$%,I'
Exercice#1.
#(obligatoire)#Utilisation#de#bibliothèques#et#Classe#Atom#
[0' ,.$&#,' D,' %"?1+,/&,&' 1$10$"#5E;/,&' 2?"D/0,&6' ,%' =J#5"%7' =:+' ,.,?=0,' 0:'
1$10$"#5E;/,'?:#5';/$'*"%#$,%#'0:'3"%*#$"%'sqrt'2+:*$%,'*:++A,6I'G"/+'/#$0$&,+'0:'
3"%*#$"%' sqrt'$0' 3:/#' $?="+#,+' 0:' 1$10$"#5E;/,' ?:#5' :C,*' 0:' *"??:%D,' $?="+#'
?:#5I'[0',&#'="&&$10,'D,'+A/#$0$&,+'0,&'3"%*#$"%&';/,'C"/&':C,B'A*+$#,&'D:%&'/%':/#+,'
3$*5$,+'D,'0:'?\?,'?:%$E+,I''
@"$*$'/%',.,?=0,'D-/#$0$&:#$"%'2;/,'C"/&'="/C,B'+,*"=$,+'D:%&'/%'3$*5$,+'#,&#I=J6'
(''
# -*- coding: utf-8 *-*
import math
import TP2
def main() :
print math.sqrt(2)
print TP2.carre(math.sqrt(2)))
'
@"$*$' 0:' DA3$%$#$"%' D,' 0:' *0:&&,' ]#"?'S' +,*"=$,+' D:%&' C"#+,' 3$*5$,+'
,%3"/$&&,?,%#I=J('
class Atom:
def __init__(self, x, y, z, numRes=-1, resType=”X”, sse=”X”):
self.x = x
self.y = y
self.z = z
self.numRes=numRes #numéro PDB du résidu
self.resType=resType #code 3 lettres de l'aa
self.sse=sse #Code 1 lettre de la Structure secondaire
@"$*$'/%',.,?=0,'D,'*"??:%D,'=J#5"%'="/+'*+A,+'/%':#"?,'(''
>>>at1=Atom(0.1,-99.6, 55.4)
@"/&'="/C,B':**AD,+'S'0:'*""+D"%%A,'.':$%&$'(''
^^^'=+$%#':#ZI.'
'
)*+$+,' 0,' *"D,' D-/%,' 3"%*#$"%' distance(atom1, atom2)';/$' *:0*/0,' ,#' +,#"/+%,' 0:''
D$&#:%*,',/*0$D$,%%,',%#+,'D,/.' :#"?,&':#"?Z',#':#"?HI'F,&#,+' *,##,'3"%*#$"%'
D:%&'0,'=+">+:??,'=+$%*$=:0'2main6',%'D,?:%D:%#'S'0-/#$0$&:#,/+'0,&'*""+D"%%A,&'
D,'D,/.'="$%#&',#':33$*5,+'0:'C:0,/+'D,'0:'D$&#:%*,';/$'0,&'&A=:+,I'
Exercice#2.
(entrainement)#RMS#et#liste#d’atomes##
9,' _`<R' 2_""#' `,:%' <;/:+,' R,C$:#$"%6' ,&#' 0:' D$&#:%*,' ?"J,%%,(,%#+,' 0,&' n&
:#"?,&'D, D,/.'&#+/*#/+,&'a&,#'bI'<:'3"+?/0,',&#'0:'&/$C:%#,'('
'
"W'(x,y,z)&&"%#'0,&'*""+D"%%A,&':#"?$;/,&'*:+#A&$,%%,&I''
'
Z6 )*+$+,'0,'*"D,'D-/%,'3"%*#$"%'RMSD(L1, L2);/$'*:0*/0,'0,'_`<R',%#+,'0,&'n&
:#"?,&'D,&'D,/.'0$&#,&'9Z',#'9HI'9:'3"%*#$"%'="/++:':==,0,+'0: 3"%*#$"%'distance.'
H6 G"/+'#,&#,+'*,##,'3"%*#$"%'D:%&'0,'=+">+:??,'=+$%*$=:0'C"/&'/#$0$&,+,B'0,&'
0$&#,&' D-:#"?,&' ;/$' "%#' A#A' >A%A+A,&' S' =:+#$+' D,&' &#+/*#/+,&' ZK99',#' ZKaK'
&/=,+="&A,&' 2:=+,&' =:$+b3$#6',#' ;/$' C"/&' &"%#'D"%%A,&' D:%&' 0,' 3$*5$,+' D:#:I#.#I'
@"/&'*"=$,+,B'0,&'D,/.'C:+$:10,&'K]bZKaK',#'K]bZK99'D:%&'C"#+,'3"%*#$"%'?:$%I'
G"/+' CA+$3$,+' ;/,' 0,' _`<' ;/,' C"/&' *:0*/0,B' ,&#' *"++,*#7' C"/&' ="/++,B' C"/&'
*"?=:+,+':/'+?&'+,#"/+%A'=:+'0:'3"%*#$"%'+?&b*/+'D:%&'=J?"0I'9,&'3$*5$,+&'=D1'
*"%#,%:%#' 0,&' &#+/*#/+,&' &/=,+="&A,&' C"/&' &"%#' D"%%A,&' 2ZKaKb&/=,+=I,%#' ,#'
ZK99b&/=,+=I,%#6'
Exercice#3.
(obligatoire)#Sélection#des#atomes#proches
#
Z6 )*+$+,'0,'*"D,'D-/%,'3"%*#$"%'Env(atomeRef, rc, lesAtomes) ;/$'=+,%D',%'
:+>/?,%#'/%':#"?,'atomeRef7'/%,'D$&#:%*,'rc',#'/%,'0$&#,'D-:#"?,&'lesAtomes',#';/$'
+,#"/+%,'0:'0$&#,&'D,&':#"?,&'S'/%,'D$&#:%*,'$%3A+$,/+,'S rc&X'D,'0-:#"?,'atomeRef.&'
'
H6 [0',&#'D$33$*$0,'D,'&:C"$+'&$'0,'+A&/0#:#',&#'*"++,*#I'G"/+'#,&#,+'C"#+,'3"%*#$"%7'
%"/&':00"%&'C$&/:0$&,+'0,&':#"?,&'&A0,*#$"%%A&'D:%&'=J?"0I'G"/+'*,0:7'C"/&'A*+$+,B'
/%,'3"%*#$"%'print_select_pymol(lesAtomes, objetPymol, nomSel) ;/$'A*+$+:'D:%&'0,'
#,+?$%:0'0:'*"??:%D,'D,'&A0,*#$"%'="/+'=J?"0I'9-:+>/?,%#'objetPymol ,&#'0,'%"?'
D,'0-"1U,#'S'&A0,*#$"%%,+',# nomSel ,&#'0,'%"?'D,'0:'&A0,*#$"%I''
'
G:+',.,?=0,7'%"/&':00"%&'&A0,*#$"%%,+'0,&'+A&$D/&'=+"*5,&'D/'=+,?$,+'+A&$D/'D,'
ZK99I'<$'0,&'+A&$D/&'&A0,*#$"%%A&'=:+'C"#+,'3"%*#$"%'&"%#'0,&'+A&$D/&'Hc',#'de7'C"/&'
D,C+,B':33$*5,+':C,*'C"#+,'=+">+:??,'=J#5"%'D:%&'0,'#,+?$%:0'select proche1er,
object 1cll and (resi 24 or resi 46). @"/& *"=$,+,B',%&/$#,'*,##,'*"??:%D,'
D:%&'=J?"0',#'C$&/:0$&,+,B'0:'&A0,*#$"%I'@"/&'CA+$3$,+,B',%&/$#,':C,*'0:'3"%*#$"%'
D$&#:%*,' D,' =J?"0' &$' 0:' D$&#:%*,' ,%#+,' 0,&' D,/.' K:' 0,&' =0/&' A0"$>%A&' ,&#' 1$,%'
$%3A+$,/+,'"/'A>:0,'S'ZYI'
Exercice#4.
#(obligatoire)#Calcul#vectoriel#
Z6 )*+$+,' 0,' *"D,' D-/%,' 3"%*#$"%' Rij(ati, atj) ;/$' *:0*/0,' ,#' +,#"/+%,' 0,&'
*""+D"%%A,&'D/'C,*#,/+ +$U'S'=:+#$+'D,&'*""+D"%%A,&'D,&':#"?,&'ati',#'atjI'K,&'
*""+D"%%A,&'&"%#'+,=+A&,%#A,&'=:+'/%'#/=0,'(x,y,z).'
H6 )*+$+,' 0,' *"D,' D-/%,' 3"%*#$"%' Norme(x,y,z) ;/$' +,#"/+%,' 0:' %"+?,' D-/%'
C,*#,/+'S'=:+#$+'D, &,&'*""+D"%%A,&I'
Exercice#5.
#(obligatoire)#Calcul#de#la#variance#circulaire.#
Z6 )*+$+,'0,'*"D,'D-/%,'3"%*#$"%'CVi(ati, rc, lesAtomes) ;/$'*:0*/0,',#'+,#"/+%,'
0:' C:+$:%*,' *$+*/0:$+,' D, 0-:#"?,' ati&S' =:+#$+' D,' 0:' 0$&#,' D-:#"?,&' lesAtomes'
*"%#,%:%#'0,&'*""+D"%%A,&'D, tous'0,&':#"?,&'D-/%,'=+"#A$%,',#'D,'0:'D$&#:%*,'rc'
2,%' ]7' D$&#:%*,' ?:.$?:0,' ="/+' ;/,' H' :#"?,&' &"$,%#' *"%&$DA+A&' *"??,'
&/33$&:??,%#'=+"*5,&6'I'
H6 )*+$+,' 0,' *"D,' D-/%,' 3"%*#$"%' CV_AllRes(lesAtomes, rc=12);/$' +,#"/+%,' 0:'
C:+$:%*,'*$+*/0:$+,'="/+'#"/&'0,&':#"?,&'D,'0:'0$&#,'0,&]#"?,&',#',%'%,'=+,%%:%#'
,%'*"?=#,';/,'0,&':#"?,&'S'?"$%&'D,'rc]I'9-:+>/?,%#'+*':'="/+'C:0,/+'=:+'DA3:/#'
ZH]',#' $0'=,/#' D"%*' \#+,' "?$&' 0"+&' D,' 0-:==,0I' 9,&' C:+$:%*,&' *:0*/0A,&' &,+"%#'
+,#"/+%A,&'&"/&'0:'3"+?,'D-/%,'0$&#,'D"%#'0-"+D+,'&,+:'0,'?\?,';/,'0-"+D+,'D,&'
:#"?,&'D:%&'0:'0$&#,'lesAtomesI'
Exercice#6.
(obligatoire)#Affichage#de#l’enfouissement#
G"/+' 3$%$+7' C"/&' C"/&' A*+$+,B' /%,' 3"%*#$"%' Atomes_Enfouis(lesAtomes, lesCV,
seuilCV) ;/$'+,#"/+%,'0:'0$&#,'D,&':#"?,&',%3"/$&'2D"%#'0:'C:+$:%*,'*$+*/0:$+,',&#'
&/=A+$,/+,':/'&,/$06I'
R:%&' 0,' main7' C"/&' *:0*/0,+,B' 0:' C:+$:%*,' *$+*/0:$+,' D,&' K:' D-/%,' D,&' D,/.'
=+"#A$%,&' D"%%A,&' ,#' C"/&' :33$*5,+,B' /%,' &,0,*#$"%' ="/+' =J?"0' ;/$' C"/&'
=,+?,##+:' D,' C$&/:0$&,+' 0,&' +A&$D/&' ,%3"/$&'D:%&' *,' 0">$*$,0I' F,&#,B' =0/&$,/+&'
C:0,/+&'D,'&,/$0'D,'D$&#:%*,'+*',#'D,'&,/$0'D,'C:+$:%*,'*$+*/0:$+,I''
!
1 / 4 100%
La catégorie de ce document est-elle correcte?
Merci pour votre participation!

Faire une suggestion

Avez-vous trouvé des erreurs dans linterface ou les textes ? Ou savez-vous comment améliorer linterface utilisateur de StudyLib ? Nhésitez pas à envoyer vos suggestions. Cest très important pour nous !