Ajout C3.tex + C3.pdf
This commit is contained in:
parent
bdc7ff7d13
commit
4c85f09c74
49 changed files with 860 additions and 0 deletions
1
C3/codes/q10_8.py
Normal file
1
C3/codes/q10_8.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
dico = { 'a': (1,2,3), 'b': (4,5,6) }
|
||||
3
C3/codes/q11_9.py
Normal file
3
C3/codes/q11_9.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
ports = { 'http': 80, 'imap': 142, 'smtp': 25 }
|
||||
ports['ftp'] = 21
|
||||
print(ports['ftp'])
|
||||
2
C3/codes/q13_10.py
Normal file
2
C3/codes/q13_10.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
P = [ {"nom":"Turing","prénom":"Alan","âge":28},{"nom":"Love
|
||||
lace","prénom":"Ada","âge":27} ]
|
||||
10
C3/codes/q14_11.py
Normal file
10
C3/codes/q14_11.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
def ajoute(stock,element,quantite):
|
||||
if element in stock:
|
||||
stock[element] = stock[element] + quantite
|
||||
else:
|
||||
stock[element] = quantite
|
||||
|
||||
stock = { 'clous': 14, 'vis': 27, 'boulons': 8,
|
||||
'écrous': 24 }
|
||||
ajoute(stock,'vis',5)
|
||||
ajoute(stock,'chevilles',3)
|
||||
1
C3/codes/q15_12.py
Normal file
1
C3/codes/q15_12.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
D = { 'a': '1', '2': 'a', 'b': 'a', 'c': '3'}
|
||||
2
C3/codes/q16_13.py
Normal file
2
C3/codes/q16_13.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
contacts = {'Paul': '0601010182', 'Jacques': '0602413824',
|
||||
'Claire': '0632451153'}
|
||||
5
C3/codes/q17_14.py
Normal file
5
C3/codes/q17_14.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
billes = {'vert': 6, 'rouge': 15, 'bleu': 11, 'jaune': 2,
|
||||
'orange': 17 }
|
||||
total = 0
|
||||
for n in billes.XXXXXXX():
|
||||
total = total + n
|
||||
1
C3/codes/q18_15.py
Normal file
1
C3/codes/q18_15.py
Normal file
|
|
@ -0,0 +1 @@
|
|||
dico = {"Herve": 15, "Kevin":17, "Fatima":16}
|
||||
5
C3/codes/q19_16.py
Normal file
5
C3/codes/q19_16.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
placard = { 'chemise': 3, 'pantalon': 6, 'tee shirt': 7 }
|
||||
placard['chaussette'] = 4
|
||||
placard['chemise'] = 5
|
||||
|
||||
L = list(placard.values())
|
||||
2
C3/codes/q1_1.py
Normal file
2
C3/codes/q1_1.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
d = {'couleur': 'vert', 'taille': 42,
|
||||
'marque': 'le coq sportif'}
|
||||
12
C3/codes/q20_17.py
Normal file
12
C3/codes/q20_17.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
L = []
|
||||
L.append({'marque': 'Canon', 'modele': 'EOS 7D',
|
||||
'focale': '19mm', 'flash': False})
|
||||
L.append({'marque': 'Nikon', 'modele': 'CoolPix A1000',
|
||||
'focale': '19mm', 'flash': True})
|
||||
L.append({'marque': 'Sony', 'modele': 'HK 350',
|
||||
'focale': '24mm', 'flash': False})
|
||||
L.append({'marque': 'Sony', 'modele': 'HK 350',
|
||||
'focale': '19mm', 'flash': True})
|
||||
# ……
|
||||
# et ainsi de suite, d'autres informations ont été ajoutées
|
||||
# ……
|
||||
3
C3/codes/q21_22.py
Normal file
3
C3/codes/q21_22.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
contacts = {'Toto': 'toto@nsi.fr',
|
||||
'Chloé': 'chloe@nsi.com','Paul': 'paul@nsi.net',
|
||||
'Clémence': 'clemence@nsi.org' }
|
||||
4
C3/codes/q22_23.py
Normal file
4
C3/codes/q22_23.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
t = [{'type': 'marteau', 'prix': 17,
|
||||
'quantité': 32},{'type': 'scie', 'prix': 24,
|
||||
'quantité': 3},{'type': 'tournevis', 'prix': 8,
|
||||
'quantité': 45}]
|
||||
5
C3/codes/q23_24.py
Normal file
5
C3/codes/q23_24.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
t = [ {'id':1, 'age':23, 'sejour':'PEKIN'},{'id':2,
|
||||
'age':27, 'sejour':'ISTANBUL'},{'id':3, 'age':53,
|
||||
'sejour':'LONDRES'},{'id':4, 'age':41,
|
||||
'sejour':'ISTANBUL'},{'id':5, 'age':62,
|
||||
'sejour':'RIO'},{'id':6, 'age':28, 'sejour':'ALGER'}]
|
||||
7
C3/codes/q24_25.py
Normal file
7
C3/codes/q24_25.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
dict = {"alexandre" : 17, "mehdi" : 18, "jeanne" : 16,"char
|
||||
lotte" : 19, "celina" : 18, "noé" : 19}
|
||||
|
||||
def f(dic):
|
||||
for cle, valeur in dic.items() :
|
||||
if valeur > 18:
|
||||
return cle
|
||||
2
C3/codes/q26_26.py
Normal file
2
C3/codes/q26_26.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
notes = {"Paul": 12, "Jean": 16, "Clara": 14, "Aïssa": 18}
|
||||
t = list(notes.keys())
|
||||
5
C3/codes/q27_27.py
Normal file
5
C3/codes/q27_27.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
repertoire = [{'nom':'Dupont', 'tel':'5234'},{'nom':'Tournes
|
||||
ol', 'tel':'5248'}, {'nom':'Dupond', 'tel':'3452'}]
|
||||
for i in range(len(repertoire)):
|
||||
if ...... :
|
||||
print(repertoire[i]['tel'])
|
||||
3
C3/codes/q28_28.py
Normal file
3
C3/codes/q28_28.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
T = [{'fruit': 'banane', 'nombre': 25}, {'fruit': 'orange',
|
||||
'nombre': 124}, {'fruit': 'pomme', 'nombre': 75},
|
||||
{'fruit': 'kiwi', 'nombre': 51}]
|
||||
3
C3/codes/q29_29.py
Normal file
3
C3/codes/q29_29.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
repertoire = [{'nom':'Dupont', 'tel':'5234'},
|
||||
{'nom':'Tournesol', 'tel':'5248'}, {'nom':'Dupond',
|
||||
'tel':'3452'}]
|
||||
8
C3/codes/q30_30.py
Normal file
8
C3/codes/q30_30.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
t = [ {'id':1, 'age':23, 'sejour':'PEKIN'},{'id':2,
|
||||
'age':27, 'sejour':'ISTANBUL'},{'id':3, 'age':53,
|
||||
'sejour':'LONDRES'},{'id':4, 'age':41,
|
||||
'sejour':'ISTANBUL'},{'id':5, 'age':62,
|
||||
'sejour':'RIO'},{'id':6, 'age':28, 'sejour':'ALGER'}]
|
||||
|
||||
r = [ c for c in t if c['age']>30 and
|
||||
c['sejour']=='ISTANBUL' ]
|
||||
5
C3/codes/q31_31.py
Normal file
5
C3/codes/q31_31.py
Normal file
|
|
@ -0,0 +1,5 @@
|
|||
t = [ {'id':1, 'age':23, 'sejour':'PEKIN'},{'id':2,
|
||||
'age':27, 'sejour':'ISTANBUL'},{'id':3, 'age':53,
|
||||
'sejour':'LONDRES'},{'id':4, 'age':41,
|
||||
'sejour':'ISTANBUL'},{'id':5, 'age':62,
|
||||
'sejour':'RIO'},{'id':6, 'age':28, 'sejour':'ALGER'}]
|
||||
2
C3/codes/q32_32.py
Normal file
2
C3/codes/q32_32.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
{ 'nom': 'Jérôme', 'NSI': 16.2, 'maths': 11.4,
|
||||
'physique': 13.0 }
|
||||
12
C3/codes/q32_33.py
Normal file
12
C3/codes/q32_33.py
Normal file
|
|
@ -0,0 +1,12 @@
|
|||
def somme(notes):
|
||||
return notes['NSI'] + notes['maths'] + notes['physique']
|
||||
|
||||
def plusPetit(n1, n2):
|
||||
if n1['NSI'] < n2['NSI']:
|
||||
return True
|
||||
if n1['NSI'] == n2['NSI']:
|
||||
if somme(n1) < somme(n2):
|
||||
return True
|
||||
elif somme(n1) == somme(n2) and n1['nom'] < n2['nom']:
|
||||
return True
|
||||
return False
|
||||
10
C3/codes/q32_34.py
Normal file
10
C3/codes/q32_34.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
n1 = { 'nom': "Albert", 'NSI': 12.3, 'maths': 14.0,
|
||||
'physique': 8.7 }
|
||||
n2 = { 'nom': "Béatrice", 'NSI': 12.3, 'maths': 11.0,
|
||||
'physique': 12.5 }
|
||||
n3 = { 'nom': "Colin", 'NSI': 12.3, 'maths': 7.0,
|
||||
'physique': 15.7 }
|
||||
n4 = { 'nom': "Daniel", 'NSI': 13.4, 'maths': 9.0,
|
||||
'physique': 5.2 }
|
||||
n5 = { 'nom': "Emilie", 'NSI': 16.1, 'maths': 5.3,
|
||||
'physique': 14.4 }
|
||||
10
C3/codes/q33_35.py
Normal file
10
C3/codes/q33_35.py
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
relevé = [{'matière':'EPS','moyenne':11},
|
||||
{'matière':'Sciences','moyenne':6},
|
||||
{'matière':'LV1','moyenne':14},
|
||||
{'matière':'Histoire','moyenne':9},
|
||||
{'matière':'LV2','moyenne':15}]
|
||||
a = ......
|
||||
b = ......
|
||||
for i in relevé :
|
||||
if i[a] > 10:
|
||||
print(i[b])
|
||||
3
C3/codes/q33_36.py
Normal file
3
C3/codes/q33_36.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
EPS
|
||||
LV1
|
||||
LV2
|
||||
4
C3/codes/q34_41.py
Normal file
4
C3/codes/q34_41.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
stock = [{'nom': 'flageolets', 'quantité': 50,
|
||||
'prix': 5.68},{'nom': 'caviar', 'quantité': 0,
|
||||
'prix': 99.99},.........,.........,{'nom': 'biscuits',
|
||||
'quantité': 100, 'prix': 7.71}]
|
||||
8
C3/codes/q35_42.py
Normal file
8
C3/codes/q35_42.py
Normal file
|
|
@ -0,0 +1,8 @@
|
|||
def clearfield(f):
|
||||
for i in range(len(f)):
|
||||
fiche[i]['code'] = None
|
||||
return f
|
||||
|
||||
fiche = [{"nom": "pierre", "note": 5.99,
|
||||
"code": 125},{"nom": "pol", "note": 2.99,
|
||||
"code": 82},{"nom": "jack", "note": 7.99, "code": 135}]
|
||||
3
C3/codes/q36_47.py
Normal file
3
C3/codes/q36_47.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
repertoire = [{'nom': 'Francette',
|
||||
'poste': 412},{'nom': 'Jeanne',
|
||||
'poste': 222},{'nom': 'Éric', 'poste': 231}]
|
||||
7
C3/codes/q7_2.py
Normal file
7
C3/codes/q7_2.py
Normal file
|
|
@ -0,0 +1,7 @@
|
|||
inventaire = {'pommes': 430, 'bananes': 312,'oranges' : 274,
|
||||
'poires' : 137}
|
||||
|
||||
stock = 0
|
||||
for fruit in inventaire.keys():
|
||||
if fruit != 'bananes':
|
||||
stock = stock + inventaire[fruit]
|
||||
2
C3/codes/q8_3.py
Normal file
2
C3/codes/q8_3.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
P = [{"nom":"Turing","prénom":"Alan","âge":28},{"nom":"Lovel
|
||||
ace","prénom":"Ada","âge":27}]
|
||||
3
C3/codes/r20_a.py
Normal file
3
C3/codes/r20_a.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Z = [ p for p in L if (p['marque'] == 'Canon' or
|
||||
p['focale'] == '19mm') and (p['marque'] == 'Nikon' or p[
|
||||
'focale'] == '19mm') ]
|
||||
3
C3/codes/r20_b.py
Normal file
3
C3/codes/r20_b.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Z = [ p for p in L if (p['marque'] == 'Canon' and
|
||||
p['focale'] == '19mm') and (p['marque'] == 'Nikon' and p
|
||||
['focale'] == '19mm') ]
|
||||
3
C3/codes/r20_c.py
Normal file
3
C3/codes/r20_c.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Z = [ p for p in L if (p['marque'] == 'Canon' or
|
||||
p['focale'] == '19mm') or (p['marque'] == 'Nikon' or p['
|
||||
focale'] == '19mm') ]
|
||||
3
C3/codes/r20_d.py
Normal file
3
C3/codes/r20_d.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
Z = [ p for p in L if (p['marque'] == 'Canon' and
|
||||
p['focale'] == '19mm') or (p['marque'] == 'Nikon' and p[
|
||||
'focale'] == '19mm') ]
|
||||
2
C3/codes/r33_a.py
Normal file
2
C3/codes/r33_a.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
a = 'moyenne'
|
||||
b = 'matière'
|
||||
2
C3/codes/r33_b.py
Normal file
2
C3/codes/r33_b.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
a = 'matière
|
||||
b = 'moyenne'
|
||||
2
C3/codes/r33_c.py
Normal file
2
C3/codes/r33_c.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
a = 0
|
||||
b = 1
|
||||
2
C3/codes/r33_d.py
Normal file
2
C3/codes/r33_d.py
Normal file
|
|
@ -0,0 +1,2 @@
|
|||
a = 1
|
||||
b = 0
|
||||
3
C3/codes/r35_a.py
Normal file
3
C3/codes/r35_a.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[{"nom": "pierre", "note": 5.99,
|
||||
"code": 125},{"nom": "pol", "note": 2.99,
|
||||
"code": 82},{"nom": "jack", "note": 7.99, "code": 135}]
|
||||
3
C3/codes/r35_b.py
Normal file
3
C3/codes/r35_b.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[{"nom": "pierre", "note": None,
|
||||
"code": 125},{"nom": "pol", "note": None,
|
||||
"code": 82},{"nom": "jack", "note": None, "code": 135}]
|
||||
3
C3/codes/r35_c.py
Normal file
3
C3/codes/r35_c.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
[{"nom": "pierre", "note": 5.99,
|
||||
"None": 125},{"nom": "pol", "note": 2.99,
|
||||
"None": 82},{"nom": "jack", "note": 7.99, "None": 135}]
|
||||
4
C3/codes/r35_d.py
Normal file
4
C3/codes/r35_d.py
Normal file
|
|
@ -0,0 +1,4 @@
|
|||
[{"nom": "pierre", "note": 5.99,
|
||||
"code": None},{"nom": "pol", "note": 2.99,
|
||||
"code": None},{"nom": "jack", "note": 7.99,
|
||||
"code": None}]
|
||||
3
C3/codes/r9_a.py
Normal file
3
C3/codes/r9_a.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
effectifs = {'A':0, 'B':0, 'C':0, 'D':0}
|
||||
for lettre in sequence:
|
||||
effectifs[lettre] = effectifs[lettre] + 1
|
||||
3
C3/codes/r9_b.py
Normal file
3
C3/codes/r9_b.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
effectifs = {}
|
||||
for lettre in sequence:
|
||||
effectifs[lettre] = effectifs[lettre] + 1
|
||||
3
C3/codes/r9_c.py
Normal file
3
C3/codes/r9_c.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
effectifs = {'A':0, 'B':0, 'C':0, 'D':0}
|
||||
for lettre in effectifs.keys():
|
||||
effectifs[lettre] = len([lettre in effectifs])
|
||||
3
C3/codes/r9_d.py
Normal file
3
C3/codes/r9_d.py
Normal file
|
|
@ -0,0 +1,3 @@
|
|||
effectifs = {}
|
||||
for lettre in effectifs.keys():
|
||||
effectifs[lettre] = len([lettre in effectifs])
|
||||
Loading…
Add table
Add a link
Reference in a new issue