-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCours 6.py
More file actions
60 lines (45 loc) · 1.42 KB
/
Copy pathCours 6.py
File metadata and controls
60 lines (45 loc) · 1.42 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
Liste = ["Nicolas", "Teanie", "Mathias", "Tara", "Cléa"]
print(Liste)
for Element in Liste:
print(Element)
print(Liste[0:2])
Liste.append("A")
print(Liste)
Liste.remove("A")
print(Liste)
#Liste [ ... , ... ] -> mutable
#Tuple ( ... , ... ) -> immutable
tuple = ("Nicolas", "Teanie", "Mathias", "Tara", "Cléa")
#Set { ... , ... } -> non ordonné et ne peux pas contenir de doublons
set = {"Nicolas", "Teanie", "Mathias", "Tara", "Cléa"}
print(Liste[:2])
print(Liste[2:])
Liste2 = [3.14, 7, -2 + 3j, "water", False, [1, 2], 5, "Hello", "Hi", "7", "e"]
print(Liste2[::3])
print(Liste2[-1])
ElementSupprimé = Liste2.pop();
print(ElementSupprimé)
print(Liste2)
n = int(input("Entrez un entier > "))
liste = []
for i in range(n):
liste.append(1/(i+1))
print("La somme vaut {} !".format(round(sum(liste), 2)))
string = "1,2,3"
print(string.split(","))
n = int(input("Entrez un entier > "))
liste = []
for i in range(n+1):
liste.append(str(i**2))
print("La liste des carrés de ces entiers est : {}.".format(", ".join(liste)))
noms = []
notes = []
string = "a"
while string != "":
string = str(input("Entrez un nom > "))
if string != "":
noms.append(string)
notes.append(int(input("Entrez sa note > ")))
print("La moyenne des élèves est {}".format(sum(notes)/len(notes)))
for i in range(len(noms)):
print(noms[i] + " : " + str(notes[i]))