POO
Exercices de POO - série 4
Exercice 1 : Élève en POO
On souhaite dans cet exercice créer une classe Eleve
ayant quatre attributs :
un prénom prenom
de type str
;
un nom nom
de type str
;
une classe classe
de type str
;
des moyennes moyennes
de type dict
. Ce dictionnaire associe à des intitulés de matières (str
), les moyennes correspondantes (au format int
ou float
).
Cet exercice est en plusieurs parties et demande de compléter la classe Eleve
en ajoutant différentes méthodes.
Il est progressif, il ne faut pas passer à la question suivante sans avoir terminé celle en cours.
Constructeur
Lors de la création d'un objet de type Eleve
, on fournit les valeurs des attributs prenom
, nom
et classe
(dans cet ordre ).
L'attribut moyennes
est initialement vide.
Compléter le constructeur de la classe Eleve
.
Exemple
>>> albert = Eleve ( "Albert" , "Einstein" , "Te2" )
>>> albert . prenom
'Albert'
>>> albert . nom
'Einstein'
>>> albert . classe
'Te2'
>>> albert . moyennes
{}
Version vide Version à compléter
.128013ldy1,4{k/eibmc:_35}aPr =of.gt26sShE)(punv050c0k0D0u0l0b0G0x0o0b0u0G0G0y010D0l0M010406050G0N0n0n0u0w0d040H0z0b0N0*0z0O050j0;0?0^0`0/0M04051a131d0j1a0/0c0l0P0Y0!0$0(0I0l0C0I0b1r0I0D0-050T0m0b0k1m0#0%011q1s1u1s0D1A1C1y0D0w1b0D0I0Y0}0G0M0u0O0(0E011E1o010A0V0k0O0u0n0k1y1X1Z1(1G1+1C1.1:0-0a0x0v0w0z0M0z0G0l100O0x0R1V0w0w0k0o28131?0O1b0j1T2l1Q1S1R1z0c1^0(1u0O1-251y1j1l0Z1F2v0l2x0O0z2B1y0M2e1b2j2l2P0:1Y292D1)2I0w0@0b0-0e2i2T0.2S1@2V1G2X2Z0-0E2%1Z2)2j2u012.0u2!040r2=2k0/2^2,0(2{2}0g302@2T2_360-0s39323b342`0z2Y2|0-0F391e2N132B2o0c1S2t3j0o2J1;1b3u1c3s2R142(053A0R2O3i1n1G0i0-2,390x2*2U3P350o0-0J1C0P0k3q333Y010,040p3g0x3=3V3+2E013R040R0A3U3W2_0A0n0-0q0q2G27453*3O3_3.0L4a2+3,0m3.0G0k0b3~3I2?403j3.0f3 3^2W0-2M2y0n4f3X4c0-4t4o2k3@4b4w042I4A4G3N4g4D044F2P4I4Q4K2,3)4O4q3,3.0K3:4O063?4,4V4C1)4i0-4k4m4B2_0z0-0B4^3j0O4x2e4M4u4J1G4`040y534W2-504z3;4-3=4#3_4;044?4n2R4v554{4}3,4 4L0z4N4U5h1)56584O4.3c0-524*5f5g5o0(5j5l5r3_564|4!5K2`3S3P4Z5x5T5A594/5b044Y5e5f5y1G5M4l5m3J5Z5q5S54350-0n0z0d1-2x0G5#4_0-5B5Y5^3-0-0h0t3g133L0k2l4y2l3E2m3w132p6l0u1B6e3t1k2)0j0R0T0V0G04.
.128013ldy1,4{k/eibmc:_35}aPr =of.gt26sShE)(punv050c0k0D0u0l0b0G0x0o0b0u0G0G0y010D0l0M010406050G0N0n0n0u0w0d040H0z0b0N0*0z0O050j0;0?0^0`0/0M04051a131d0j1a0/0c0l0P0Y0!0$0(0I0l0C0I0b1r0I0D0-050T0m0b0k1m0#0%011q1s1u1s0D1A1C1y0D0w1b0D0I0Y0}0G0M0u0O0(0E011E1o010A0V0k0O0u0n0k1y1X1Z1(1G1+1C1.1:0-0a0x0v0w0z0M0z0G0l100O0x0R1V0w0w0k0o28131?0O1b0j1T2l1Q1S1R1z0c1^0(1u0O1-251y1j1l0Z1F2v0l2x0O0z2B1y0M2e1b2j2l2P0:1Y292D1)2I0w0@0b0-0e2i2T0.2S1@2V1G2X2Z0-0E2%1Z2)2j2u012.0u2!040r2=2k0/2^2,0(2{2}0g302@2T2_360-0s39323b342`0z2Y2|0-0F391e2N132B2o0c1S2t3j0o2J1;1b3u1c3s2R142(053A0R2O3i1n1G0i0-2,390x2*2U3P350o0-0J1C0P0k3q333Y010,040p3g0x3=3V3+2E013R040R0A3U3W2_0A0n0-0q0q2G27453*3O3_3.0L4a2+3,0m3.0G0k0b3~3I2?403j3.0f3 3^2W0-2M2y0n4f3X4c0-4t4o2k3@4b4w042I4A4G3N4g4D044F2P4I4Q4K2,3)4O4q3,3.0K3:4O063?4,4V4C1)4i0-4k4m4B2_0z0-0B4^3j0O4x2e4M4u4J1G4`040y534W2-504z3;4-3=4#3_4;044?4n2R4v554{4}3,4 4L0z4N4U5h1)56584O4.3c0-524*5f5g5o0(5j5l5r3_564|4!5K2`3S3P4Z5x5T5A594/5b044Y5e5f5y1G5M4l5m3J5Z5q5S54350-0n0z0d1-2x0G5#4_0-5B5Y5^3-0-0h0t3g133L0k2l4y2l3E2m3w132p6l0u1B6e3t1k2)0j0R0T0V0G04.
Méthode modifie_moyenne
La méthode modifie_moyenne
prend deux paramètres, un intitulé de matière (str
) et une moyenne (au format int
ou float
) et ajoute ce couple (clé: valeur)
à l'attribut moyennes
d'un objet Eleve
.
Écrire la méthode modifie_moyenne
.
Exemple
>>> carl = Eleve ( "Carl Friedrich" , "Gauss" , "Te3" )
>>> carl . modifie_moyenne ( "arithmétique" , 20 )
>>> carl . modifie_moyenne ( "chimie" , 12 )
>>> carl . moyennes
{'arithmétique': 20, 'chimie': 12}
>>> carl . modifie_moyenne ( "chimie" , 13 )
>>> carl . moyennes
{'arithmétique': 20, 'chimie': 13}
Méthode moyenne_de
La méthode moyenne_de
prend en unique paramètre un intitulé de matière (str
) et renvoie la moyenne de cet élève dans cette matière.
Si l'élève ne possède pas de moyenne dans cette matière, la fonction renverra None
.
Écrire la méthode moyenne_de
.
Exemple
>>> donald = Eleve ( "Donald" , "Knuth" , "Te7" )
>>> donald . modifie_moyenne ( "informatique" , 20 )
>>> donald . modifie_moyenne ( "musique" , 13 )
>>> donald . moyenne_de ( "informatique" )
20
>>> donald . moyenne_de ( "musique" )
13
>>> donald . moyenne_de ( "lancer de javelot" )
>>>
Version vide Version à compléter
.1280130ldy1,48{Aê]ké/weibmc:_35qaPr} 7=9o[f.;tRg26sShE()pNunv050d0r0O0B0s0c0T0F0v0c0B0T0T0H010O0s0Z010406050T0#0u0u0B0D0e040U0J0c0#0{0J0$0F020B0u0Z0N0F0P0r150D0A0#0r0T050p12141618100Z04051D1w1G0p1D100d0s0%0:0=0@0_0V0s0Q0V0c1U0V0O0~050+0t0c0r1P0?0^011T1V1X1V0O1%1)1#0O0D1E0O0V0:1b0T0Z0B0$0_0R011+1R010L0-0r0$1j0r1#2123281-2b1)2e0u2g040a0F0C0D0J0Z0J0T0s1e1g0)1 0D0D0r0v2B1w2i0$1E0p1}2N1`1|1{1$0d2k0_1X0$2d2y1#1M1O0;1,2X0s2Z0$0J2%1#0Z2G1E2L2N2^11221g2)292.0D150c0~0F0f2K2|0 2{2j2~1-3032340R3723392L2W013e0B33040F0y3i2M103l3c0_3o3q0F0h3u3k2|3m3A340z3E3w3G3y3n0J313p340S3L3a2}1Q3d3Q3f3r0G3V3x3Y3z3!3S3r0i3(3N3*3P3R3B0I3:3b3=3I040f0b3`3X2*3?3#0f361x383M3{433}0f3h483j4a422 3,3q0f3t4g3v3W3H4l0~0f3D4p3F4b4k3@4u3K4x1H2?1w2%2Q0d1|2V3O0v2/2q0(1N1E2=0r2@383E054O0)4W4z1-0n0~3c3E0F4r3O0$0v0~0W1)0%0r4Y3)430}040w3L0F514-4{294)040)0L4,4.3=0L0u0~0x0x2,2A5g4`3;4|0~0X5l4%0_0t4}0T0r0c594E541-4}0g5a5A3z0~4U2.0u5q4j5B0~5D4x535m2 0~5J5L3m5C5E5S3d4*3Y4_5z5!0_4}0Y4 4x06525;5R5r015t0~5v5x5W3O0J0~0M5}3|5H2G5V5Q5b435 040H5Z5@0$642!5K5/5=5268295_045{5y2`5F016a615)6e5U0J6i2^5?5M0_6a6c676t6f04662^5:6k6D3m6o6q6269606U5T043c5(6C6m1-6G6d6E3n5$1,6#496P6Q3O6S5w6r4X6t6v6X5#040u0J0e2d2Z1v6I5*6u0~6H6$6t4}0j0E3L6O516%0_56586*3H0L0~701M2b0r0x70720$2Z6}5+5o7A5^5u6^7D5Y766y6 0B0{0r2G7H5O7n4/7q71736/3j7j015,5.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1V0O1%1)1#0O0D1E0O0V0:1b0T0Z0B0$0_0R011+1R010L0-0r0$1j0r1#2123281-2b1)2e0u2g040a0F0C0D0J0Z0J0T0s1e1g0)1 0D0D0r0v2B1w2i0$1E0p1}2N1`1|1{1$0d2k0_1X0$2d2y1#1M1O0;1,2X0s2Z0$0J2%1#0Z2G1E2L2N2^11221g2)292.0D150c0~0F0f2K2|0 2{2j2~1-3032340R3723392L2W013e0B33040F0y3i2M103l3c0_3o3q0F0h3u3k2|3m3A340z3E3w3G3y3n0J313p340S3L3a2}1Q3d3Q3f3r0G3V3x3Y3z3!3S3r0i3(3N3*3P3R3B0I3:3b3=3I040f0b3`3X2*3?3#0f361x383M3{433}0f3h483j4a422 3,3q0f3t4g3v3W3H4l0~0f3D4p3F4b4k3@4u3K4x1H2?1w2%2Q0d1|2V3O0v2/2q0(1N1E2=0r2@383E054O0)4W4z1-0n0~3c3E0F4r3O0$0v0~0W1)0%0r4Y3)430}040w3L0F514-4{294)040)0L4,4.3=0L0u0~0x0x2,2A5g4`3;4|0~0X5l4%0_0t4}0T0r0c594E541-4}0g5a5A3z0~4U2.0u5q4j5B0~5D4x535m2 0~5J5L3m5C5E5S3d4*3Y4_5z5!0_4}0Y4 4x06525;5R5r015t0~5v5x5W3O0J0~0M5}3|5H2G5V5Q5b435 040H5Z5@0$642!5K5/5=5268295_045{5y2`5F016a615)6e5U0J6i2^5?5M0_6a6c676t6f04662^5:6k6D3m6o6q6269606U5T043c5(6C6m1-6G6d6E3n5$1,6#496P6Q3O6S5w6r4X6t6v6X5#040u0J0e2d2Z1v6I5*6u0~6H6$6t4}0j0E3L6O516%0_56586*3H0L0~701M2b0r0x70720$2Z6}5+5o7A5^5u6^7D5Y766y6 0B0{0r2G7H5O7n4/7q71736/3j7j015,5.6N6;7Z6@5|6x6+6|7,3H7U7x747Q040K7D6K157N7P7/3O4}0m7S3=6)7J6+7{7V7y7X3v7h6=3=7l0r6_3j8e4c7p6 892Z0x0)7@5p7 3=7*8i2M7Z7I7b777{7M0s7O8b4$6+7#506P7Z560s8x3r7Z8D7}8H8k290J0q0~2,83438w7D7.6s8C7;7W758+5@4}7$6:6;6l6t562G0O0#0D0$8$6n7F7+8:7-6W8u4c8-8a8/6`774}7_986Y7|8F7~955X0~826j8M8`0~5w5v7@8?4h8^8_778{0*8~90863m0n4;040!1f8H100p4!4V4F9R0p4I1w0O4K9W2T2O0B1(9T4I1C8I3m2G0u0x0L0B0n7u0V0y0~1o1q1s1u0F9x8y1J391D9L0O1f0T0g0F1s002d2t0e1}1fa80#2Z0F0L1f2I0s1f0F0T230/4Z4P3m1/1W1Y1!9+3O9C8}8 4Y9P4P3r650%0J8F0F220D0F0d0o9:1d4-9Qaw1Y1;1Z2h9B9J9L7z4EaH4#6w1K1F040k2,2z0F1)1 2D2=0o0v0o0)0$0OaO0J8~0D0,b20l1`1*a}0D2Aaqasa^1*au2D3Oaxa!aA8N9t0.8H1w9Q3r1s0saq7Ob70F0Q0o0D0o0F0s1k1X0v2A1p2db25.a/2%aY1:az2;4G2`4Ebubp578h913d8m7w7W8qbs7c7C9h1-8(b:7B045P8B7K9j8G7@5-8L7i9s048Pb%5G7L8Uc56u8Zc39Fb`6+b=9m5~97ch638n7=1u9wc05=b!8|9Ec9cg9d5@8*cx879a7?b?7!0~9gck99c79kb-9e9o3Va,9T4U2N9)4H0*0,0.04.
Méthode moyenne_simple
La méthode moyenne_simple
calcule et renvoie la moyenne générale de l'élève. Celle-ci se calcule en effectuant la moyenne des moyennes.
Si l'élève n'a aucune moyenne, la fonction renverra None
.
Écrire la méthode moyenne_simple
.
Exemple
>>> jane = Eleve ( "Jane" , "Goodall" , "Te3" )
>>> jane . modifie_moyenne ( "éthologie" , 20 )
>>> jane . modifie_moyenne ( "théorie des groupes" , 1 )
>>> jane . moyenne_simple ()
10.5
Version vide Version à compléter
.128013Cy1{ê]/wi_}qP+r 79f;gR2àhE()pNn0ld,4Akéebmc:35a=o[.8t6sSuxv050I0O0#0V0j0H0%0q0R0H0V0%0%0W010#0j0D010406050%0)0Q0Q0V0p0c040(0X0H0)0 0X0F0q020V0Q0D0u0q0w0O190p0m0)0O0%050h16181a1c140D04051H1A1K0h1H140I0j0+0@0_0{0}0z0j0v0z0H1Y0z0#12050/0P0H0O1T0`0|011X1Z1#1Z0#1+1-1)0#0p1I0#0z0@1f0%0D0V0F0}0x011/1V010t0;0O0F1n0O1)25272c1;2f1-2i0Q2k040a0q0n0p0X0D0X0%0j1i1k0-230p0p0O0R2F1A2m0F1I0h212R1~201 1*0I2o0}1#0F2h2C1)1Q1S0^1:2#0j2%0F0X2+1)0D2K1I2P2R2|15261k2-2d2=0p190H120q0d2O30132 2n321;3436380x3b273d2P2!013i0V37040q0T3m2Q143p3g0}3s3u0q0K3y3o303q3E380U3I3A3K3C3r0X353t380$3P3e311U3h3U3j3v0r3Z3B3$3D3(3W3v0!3,3R3.3T3V3F0s3@3f3_3M040d0G3~3#2.3`3)0d3a1B3c3Q3 47410d3l4c3n4e46333:3u0d3x4k3z3!3L4p120d3H4t3J4f4o3{4y3O4B4m4w4F423Y4I4v3S4h3+4O3-4g4x423?4T3^4V4L0d3}4Z4D3%4L0x444)4n4+3)0x4b2|4J4Q4W0x4j2~1N2`1A2+2U0I202Z3S0R2?2u0,1R1I2_0O2{3c3I05580-5g4*0}0M123g3I0q4P400R120A1-0+0O5i4U2d11040S3P0q5J5t5D1;5p040-0t5s5u470t0Q120k0k2:2E5Y5C4!5E120B5%5n010P5F0%0O0H5R4B5T5)040J5S5M3D125e2=0Q5,4:0}5F5|4B5L5(3h1262643q675}6b5 043g5B5^5~015F0C5H4I5K6v6a5-5/125;5?6f3S0X120Z6D40602K6e695_1;6F040W6i5-0F6K2(636u6w5J6O0}6z046B5@2~6p6Q6H6o6j3r6d0X6Y2|6x65016Q6S6N6p6V046M4^6!6#6p6(6*6I476.7a335q3$6n6_6$6|126~7i707f1:7h4d756`3q785=6+5h6-6G7d6c040Q0X0c2h2%1z6 6;6}6T6{5F0e0l3P066v7j5O5Q7O3L0t127F1Q2f0O0k7F7H0F2%7C665*7:5.5:7x7?6h7L6U7$0V0 0O2K7`12687n6;717,7I7r3n7j6r6t74757j7w6C6:5-7c8l6{887G8a7K6,6;5F0Y7?887 0j818b2Q8d120g7Z6E7l8I6J7E8r7.8D137U5K7W127Y7|8p7#8N7-2%0k0-83045+8o7v7^8k8u5-7{867}7E8A8C8)6s5I8h6p5O0j7y3n7u4Q7~80828X3q0X0i122:8L478j928E7A046/8:8p7$8O7J8)8f7s7t8T8 122K0#0)0p0F9f2d9h7?8n9n3L9p8#1y8)8x8,958^978Q8F048H4I8S766;7X0O9i3v7j0F8Z898P0k2D1o1-8)8+9J3S9G9Q3_8e8}6!8U04919E3h0P122r9?7?9`9^3_9I7z879L8s8{a30}6Q020v0#0uaj010Q0j124.ab475F9t4l9v9waf040#0X0/0Haq7N993Sasau9~9va00t3Uaq8q0caJ9ca19DaL3_aaae8m7B9{4gag8P8ta(6{ad8c7o040+3t1xa/a?8v5*8|6ZaB7Va@aFaHaJ120o7m3c948M7,aP7ta09z9Ba!8?9oaEaG3tb7040haUa504a7a+5`9@a:8-6A7_bx6Pa*aw7e8!ahbE7;040CbfaC5-5O5=5;9sbP9 9x04bi9Caq0M5w040E1j8Q140h5k5f1L500h521A0#54b^2X2S0V1,b:b?5c1G5m6{2K0Q0k0t0V0M7*0z0T121s1u1w1y0qaz8E1N3d1H0b6@2t0q2:1Q1w0N0q0I270?0H000O0*810R0j0R1.2_0N0R0N0-0F0#0J0q1-ck6#cnc35b2,3_1?1!1$1(5d504~2~b/c43qbS0=9U6pay5s9Zbc475Ob!bkbb7Wb(b*7/4Ob.592R5e2R52060D0O1h0q0f1~1.6@0j0%6/1O1J040L2:2DcT1.b/0qcLcNcP0#0q1ydB0N1w1R3t2hdB0yck1L3d2+3qc$1^1%2^c+5h5^c.a08Wbl7!a-8$9:0D9=bL6q7=d,a%a}8;12b08g9!bR9d9(c{33bubwbH1;5Fbzd;6{d:9j7MbGbA9R9-9rd,6rbqamaoaqaN04aveb9|12cl13bgb4boaIa#7b8Kex2delenaA8~9#12aS0paU9LaX9dc 938i8.9(7ja=e88@ed9Nd,eUc/9Ra_1geYe1bM0Bd@9uaB9*12b5bpeAbF04b9eK8!bWd}5N9y0.bje{e=ewd#8Jbrbta62ha8d/eR9Heae59KbJa.aid5dY4 c0db510.0:0=04.
.128013Cy1{ê]/wi_}qP+r 79f;gR2àhE()pNn0ld,4Akéebmc:35a=o[.8t6sSuxv050I0O0#0V0j0H0%0q0R0H0V0%0%0W010#0j0D010406050%0)0Q0Q0V0p0c040(0X0H0)0 0X0F0q020V0Q0D0u0q0w0O190p0m0)0O0%050h16181a1c140D04051H1A1K0h1H140I0j0+0@0_0{0}0z0j0v0z0H1Y0z0#12050/0P0H0O1T0`0|011X1Z1#1Z0#1+1-1)0#0p1I0#0z0@1f0%0D0V0F0}0x011/1V010t0;0O0F1n0O1)25272c1;2f1-2i0Q2k040a0q0n0p0X0D0X0%0j1i1k0-230p0p0O0R2F1A2m0F1I0h212R1~201 1*0I2o0}1#0F2h2C1)1Q1S0^1:2#0j2%0F0X2+1)0D2K1I2P2R2|15261k2-2d2=0p190H120q0d2O30132 2n321;3436380x3b273d2P2!013i0V37040q0T3m2Q143p3g0}3s3u0q0K3y3o303q3E380U3I3A3K3C3r0X353t380$3P3e311U3h3U3j3v0r3Z3B3$3D3(3W3v0!3,3R3.3T3V3F0s3@3f3_3M040d0G3~3#2.3`3)0d3a1B3c3Q3 47410d3l4c3n4e46333:3u0d3x4k3z3!3L4p120d3H4t3J4f4o3{4y3O4B4m4w4F423Y4I4v3S4h3+4O3-4g4x423?4T3^4V4L0d3}4Z4D3%4L0x444)4n4+3)0x4b2|4J4Q4W0x4j2~1N2`1A2+2U0I202Z3S0R2?2u0,1R1I2_0O2{3c3I05580-5g4*0}0M123g3I0q4P400R120A1-0+0O5i4U2d11040S3P0q5J5t5D1;5p040-0t5s5u470t0Q120k0k2:2E5Y5C4!5E120B5%5n010P5F0%0O0H5R4B5T5)040J5S5M3D125e2=0Q5,4:0}5F5|4B5L5(3h1262643q675}6b5 043g5B5^5~015F0C5H4I5K6v6a5-5/125;5?6f3S0X120Z6D40602K6e695_1;6F040W6i5-0F6K2(636u6w5J6O0}6z046B5@2~6p6Q6H6o6j3r6d0X6Y2|6x65016Q6S6N6p6V046M4^6!6#6p6(6*6I476.7a335q3$6n6_6$6|126~7i707f1:7h4d756`3q785=6+5h6-6G7d6c040Q0X0c2h2%1z6 6;6}6T6{5F0e0l3P066v7j5O5Q7O3L0t127F1Q2f0O0k7F7H0F2%7C665*7:5.5:7x7?6h7L6U7$0V0 0O2K7`12687n6;717,7I7r3n7j6r6t74757j7w6C6:5-7c8l6{887G8a7K6,6;5F0Y7?887 0j818b2Q8d120g7Z6E7l8I6J7E8r7.8D137U5K7W127Y7|8p7#8N7-2%0k0-83045+8o7v7^8k8u5-7{867}7E8A8C8)6s5I8h6p5O0j7y3n7u4Q7~80828X3q0X0i122:8L478j928E7A046/8:8p7$8O7J8)8f7s7t8T8 122K0#0)0p0F9f2d9h7?8n9n3L9p8#1y8)8x8,958^978Q8F048H4I8S766;7X0O9i3v7j0F8Z898P0k2D1o1-8)8+9J3S9G9Q3_8e8}6!8U04919E3h0P122r9?7?9`9^3_9I7z879L8s8{a30}6Q020v0#0uaj010Q0j124.ab475F9t4l9v9waf040#0X0/0Haq7N993Sasau9~9va00t3Uaq8q0caJ9ca19DaL3_aaae8m7B9{4gag8P8ta(6{ad8c7o040+3t1xa/a?8v5*8|6ZaB7Va@aFaHaJ120o7m3c948M7,aP7ta09z9Ba!8?9oaEaG3tb7040haUa504a7a+5`9@a:8-6A7_bx6Pa*aw7e8!ahbE7;040CbfaC5-5O5=5;9sbP9 9x04bi9Caq0M5w040E1j8Q140h5k5f1L500h521A0#54b^2X2S0V1,b:b?5c1G5m6{2K0Q0k0t0V0M7*0z0T121s1u1w1y0qaz8E1N3d1H0b6@2t0q2:1Q1w0N0q0I270?0H000O0*810R0j0R1.2_0N0R0N0-0F0#0J0q1-ck6#cnc35b2,3_1?1!1$1(5d504~2~b/c43qbS0=9U6pay5s9Zbc475Ob!bkbb7Wb(b*7/4Ob.592R5e2R52060D0O1h0q0f1~1.6@0j0%6/1O1J040L2:2DcT1.b/0qcLcNcP0#0q1ydB0N1w1R3t2hdB0yck1L3d2+3qc$1^1%2^c+5h5^c.a08Wbl7!a-8$9:0D9=bL6q7=d,a%a}8;12b08g9!bR9d9(c{33bubwbH1;5Fbzd;6{d:9j7MbGbA9R9-9rd,6rbqamaoaqaN04aveb9|12cl13bgb4boaIa#7b8Kex2delenaA8~9#12aS0paU9LaX9dc 938i8.9(7ja=e88@ed9Nd,eUc/9Ra_1geYe1bM0Bd@9uaB9*12b5bpeAbF04b9eK8!bWd}5N9y0.bje{e=ewd#8Jbrbta62ha8d/eR9Heae59KbJa.aid5dY4 c0db510.0:0=04.
Méthode moyenne_ponderee
La méthode moyenne_ponderee
prend comme unique paramètre un dictionnaire coeffs
associant des intitulés de matières (str
) à des coefficients (au format int
ou float
).
Cette fonction calcule la moyenne pondérée de l'élève en appliquant les coefficients fournis en paramètre.
Si l'élève n'a aucune moyenne, la fonction renverra None
.
On garantit que dictionnaire coeffs
contient toutes les clés correspondant aux matières du dictionnaire moyennes
.
Écrire la méthode moyenne_ponderee
.
Exemple
>>> margaret = Eleve ( "Margaret" , "Hamilton" , "Te5" )
>>> margaret . modifie_moyenne ( "études spatiales" , 20 )
>>> margaret . modifie_moyenne ( "maths" , 14 )
>>> coeffs = { "études spatiales" : 1 , "maths" : 0.5 }
>>> margaret . moyenne_ponderee ( coeffs )
18.0
Version vide Version à compléter
.128013Cy1{ê]/wi_}qP+r 79f;gR2àhE()pNn0ld,*4Akéebmc:35a=o[.8t6sSuxv050I0P0$0W0j0H0(0q0S0H0W0(0(0X010$0j0D010406050(0*0R0R0W0p0c040)0Y0H0*100Y0F0q020W0R0D0u0q0w0P1a0p0m0*0P0(050h17191b1d150D04051I1B1L0h1I150I0j0,0^0`0|0~0z0j0v0z0H1Z0z0$13050:0Q0H0P1U0{0}011Y1!1$1!0$1,1.1*0$0p1J0$0z0^1g0(0D0W0F0~0x011:1W010t0=0P0F1o0P1*26282d1=2g1.2j0R2l040a0q0n0p0Y0D0Y0(0j1j1l0.240p0p0P0S2G1B2n0F1J0h222S1 21201+0I2p0~1$0F2i2D1*1R1T0_1;2$0j2(0F0Y2,1*0D2L1J2Q2S2}16271l2.2e2?0p1a0H130q0d2P3114302o331=3537390x3c283e2Q2#013j0W38040q0U3n2R153q3h0~3t3v0q0L3z3p313r3F390V3J3B3L3D3s0Y363u390%3Q3f321V3i3V3k3w0r3!3C3%3E3)3X3w0#3-3S3/3U3W3G0s3^3g3`3N040d0G3 3$2/3{3*0d3b1C3d3R4048420d3m4d3o4f47343;3v0d3y4l3A3#3M4q130d3I4u3K4g4p3|4z3P4C4n4x4G433Z4J4w3T4i3,4P3.4h4y433@4U3_4W4M0d3~4!4E3(4M0x454*4o4,3*0x4c2}4K4R4X0x4k4_4Q414|4t4 4V4F4?4B544#563=0x4I594+3:4-4O5f4;5h4?4T5k4L4?4Z5p4{4-4)5t514M0U4/5x4$3*0U4^3d1M2{1B2,2V0I212!3T0S2@2v0-1S1J2`0P2|5H4C055R0.5Z5g010N133h3J0q504h0S130A1.0,0P3J5;2e12040T3Q0q635:551=5,040.0t5/5}2q0R130k0k2;2F6h5|660~5 0B6m5a1=0Q5 0(0P0H6b5#6n015 0J6c6B0F135X2?0R6r5*6D6F6s3E136K6M5l6C136E4C656Q3s5-3%5{6A6#5 0C614J646:6!5*6u136w6y6U3r0Y130!6{4R6I2L6T6Z6d0~6}040X6P5*6H046J0Y6L6/6;6376016@046_6z2 6B786 6*7c6S7g7b6V787a756G7x7h4_7j7k6B7n7p703`7t7N4h6%1;6)2}6=7A137C7V7l7d3h7U4e7I7W3r7L6x7q5H7s6~7Q34130R0Y0c2i2(1A7D6#7B7z3r5 0e0l3Q066:7l686a824R0t7^2@0j2g0P0k7_7{0F2(7?1=6p8q0~7-6`7v6V6O7 7w041a100P2L8t6W046Y7!7E8C7`7|7(3o7l6,6.7H7I7l8v7/8R7;047u7r6#7d8m8P7~8(6N130Z8H8*0W8E8G8x83130g8d7O7Y8~7R8N8n8p4J88648a138c8A6V0F8f938P0k0.8H8s8`3T8Y9k6X917@8C8@0j8F8Q2R8S136-628W6B688i9r3i7^9u9w9H770i132;9M7m6v7.8H7P9m418g941z9p609C7*7J6#682L0$0*0p0F9R9o9X489W8.9d9Z8,9$8;9@9s8D9v8_9`8{048}96899E9a0P8Z2R7+8e9|8o8k2E1p1.9$6qa06t9T8wa53T8T9(6;99049G9c3M0Q132sao8H9?au8 8$8=ai7}9$0C9R78020v0$0u9R0R0j135B7:6+138U7)9)9*8B0$0Y0:0HaS90aC3TaZa#ax7*az0t3V9R8*7`aS9OaA9;a^3`aJa%5*9_bb9{9gaj8-be6|7=aq6R040,3u1ybi8!a(040B9B7ia,aa8)13a/a;a?040o7Z3dag9Y93a|9D9+139-9/b78LbB04bD3ubF0hb1aE04aGbm8IapaK48babtbcblb,a18ObhaQ87bA5*8badb19f8+aj0k2C0F0.2L9x5)8y13b+bj9nasaec9a68KbJ7#5-0Yad0tbs9y6BawbyayabaAcgbK4hb$b(b=8rcbaIcf9Vb;cdbLc1aPb)6,bFaUaWaYa!04a$b/ca9%cua}8MbXa=b89^a@bU5*a`cVbN7jclbWa:3u0k5Rcocq3w7l81c)2ec.cW3Abzcz2e68a 0pb19J8^c8d61=0Yb59Qd0ar6^9Ub)bdcX3MaO9#cOa)c:9)c=c%bFbH9=cHdocJdq71bgcNcD6o8:aN9tdd9$a8c,7X040Kdb04c`0tcp9~dNa29Ldua7dwc#bVc%c_cndZc|df7713dBdkbndYd!d)9 dK6$dOa3c89zd*c!bOb|bQ0/bSdWdzd`0178b!ef7dd.d|c|97c;cw6x6w9$a*4md5azbR9:9R0N5?040E1kc8150h5%5Y5IeK0h5L1B0$5NeP2Y2T0W1-eM5L1Hch3T2L0R0k0t0W0N8k0z0U131t1v1x1z0qeu9y1O3e1I0b7g2u0q2;1R1x0O0q0I280@0H000P0+8F0S0j0S1/2`0O0S0O0.0F0$0J0q1.e@7ke`eZ5U2-3`1@1#1%1)5W5J2 5#eJe!3`68ere4csdv6Zeod?5+ea9.ezefeB13eE954 eI5S2S5X2SeY0D0P1i0q0f1 1/7g0j0(7u1P1K040M2;2Efq1/eJ0qfifkfm0$0q1zg70O1x1S3u2ig70ye@1M3e2,3rfz1_1(2_fE5!2 fHaz9bdS3Mc0b@2(c31kc60PfMbuccdGb9dDe08zgxdHemaQe^14b{6V9Fcy7#cB2iaHb)b.cr80dFg(8BcMdtgM9AcQaVaXefd2etdwdyc@c(gOaLbI3ofRg^e7a-bfeld:d}g~c*79cTa{h4fRd8b0ejdce3b49PbTck7KgLcKhb8%hsb?9!c|e5gSfQd,a.g|dAh0af8XhrgJhtd$gAg.hvcE04d hPbnd%a4hT8IdRhpg)dUdWgQd~d$9KhWhK5~8|d+98c$g|d/c{hFh%h8hyfNhRh*dPd)hZeve8gVfTechjc?bEefehedh?h(f#gu1O5JeN5VeH0.0:0=0(04.
.128013Cy1{ê]/wi_}qP+r 79f;gR2àhE()pNn0ld,*4Akéebmc:35a=o[.8t6sSuxv050I0P0$0W0j0H0(0q0S0H0W0(0(0X010$0j0D010406050(0*0R0R0W0p0c040)0Y0H0*100Y0F0q020W0R0D0u0q0w0P1a0p0m0*0P0(050h17191b1d150D04051I1B1L0h1I150I0j0,0^0`0|0~0z0j0v0z0H1Z0z0$13050:0Q0H0P1U0{0}011Y1!1$1!0$1,1.1*0$0p1J0$0z0^1g0(0D0W0F0~0x011:1W010t0=0P0F1o0P1*26282d1=2g1.2j0R2l040a0q0n0p0Y0D0Y0(0j1j1l0.240p0p0P0S2G1B2n0F1J0h222S1 21201+0I2p0~1$0F2i2D1*1R1T0_1;2$0j2(0F0Y2,1*0D2L1J2Q2S2}16271l2.2e2?0p1a0H130q0d2P3114302o331=3537390x3c283e2Q2#013j0W38040q0U3n2R153q3h0~3t3v0q0L3z3p313r3F390V3J3B3L3D3s0Y363u390%3Q3f321V3i3V3k3w0r3!3C3%3E3)3X3w0#3-3S3/3U3W3G0s3^3g3`3N040d0G3 3$2/3{3*0d3b1C3d3R4048420d3m4d3o4f47343;3v0d3y4l3A3#3M4q130d3I4u3K4g4p3|4z3P4C4n4x4G433Z4J4w3T4i3,4P3.4h4y433@4U3_4W4M0d3~4!4E3(4M0x454*4o4,3*0x4c2}4K4R4X0x4k4_4Q414|4t4 4V4F4?4B544#563=0x4I594+3:4-4O5f4;5h4?4T5k4L4?4Z5p4{4-4)5t514M0U4/5x4$3*0U4^3d1M2{1B2,2V0I212!3T0S2@2v0-1S1J2`0P2|5H4C055R0.5Z5g010N133h3J0q504h0S130A1.0,0P3J5;2e12040T3Q0q635:551=5,040.0t5/5}2q0R130k0k2;2F6h5|660~5 0B6m5a1=0Q5 0(0P0H6b5#6n015 0J6c6B0F135X2?0R6r5*6D6F6s3E136K6M5l6C136E4C656Q3s5-3%5{6A6#5 0C614J646:6!5*6u136w6y6U3r0Y130!6{4R6I2L6T6Z6d0~6}040X6P5*6H046J0Y6L6/6;6376016@046_6z2 6B786 6*7c6S7g7b6V787a756G7x7h4_7j7k6B7n7p703`7t7N4h6%1;6)2}6=7A137C7V7l7d3h7U4e7I7W3r7L6x7q5H7s6~7Q34130R0Y0c2i2(1A7D6#7B7z3r5 0e0l3Q066:7l686a824R0t7^2@0j2g0P0k7_7{0F2(7?1=6p8q0~7-6`7v6V6O7 7w041a100P2L8t6W046Y7!7E8C7`7|7(3o7l6,6.7H7I7l8v7/8R7;047u7r6#7d8m8P7~8(6N130Z8H8*0W8E8G8x83130g8d7O7Y8~7R8N8n8p4J88648a138c8A6V0F8f938P0k0.8H8s8`3T8Y9k6X917@8C8@0j8F8Q2R8S136-628W6B688i9r3i7^9u9w9H770i132;9M7m6v7.8H7P9m418g941z9p609C7*7J6#682L0$0*0p0F9R9o9X489W8.9d9Z8,9$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9bdS3Mc0b@2(c31kc60PfMbuccdGb9dDe08zgxdHemaQe^14b{6V9Fcy7#cB2iaHb)b.cr80dFg(8BcMdtgM9AcQaVaXefd2etdwdyc@c(gOaLbI3ofRg^e7a-bfeld:d}g~c*79cTa{h4fRd8b0ejdce3b49PbTck7KgLcKhb8%hsb?9!c|e5gSfQd,a.g|dAh0af8XhrgJhtd$gAg.hvcE04d hPbnd%a4hT8IdRhpg)dUdWgQd~d$9KhWhK5~8|d+98c$g|d/c{hFh%h8hyfNhRh*dPd)hZeve8gVfTechjc?bEefehedh?h(f#gu1O5JeN5VeH0.0:0=0(04.
D'après un exercice de Nicolas Revéret
# Tests
(insensible à la casse)(Ctrl+I)
(Ctrl+Clic pour inverser les colonnes)