-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathexopartie2.py
182 lines (86 loc) · 2.23 KB
/
exopartie2.py
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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
###exercice1 echiquier
noire = "# # # # # # # #"
blanche = ""
print("")
print(" \"")
for i in range(0, 8):
if i%2 == 0:
print(" {}{}".format(noire, blanche))
else:
print(" {}{}".format(blanche, noire))
print(" \"")
print("")
###exercice2
liste = [0,0,0,0]
a = 0
b = 0
c = 0
d = 0
e = "----------"
for i in range(0, 4):
liste[i] = 1
a = liste[0]
b = liste[1]
c = liste[2]
d = liste[3]
print("{}\n{}\n{}\n{}\n{}".format(a, b, c, d, e))
liste[i] = 0
#####exercice3
a = int(input("entrer un nombre"))
if a%2 == 0 :
print (bool(a))
else:
a %2 != 0
print("false")
####exercice4
while True:
try:
N = int(input("saisir un nombre entier positf"))
if N >0 :
ft=1
for i in range(2, N+1 ):
ft*=i
print(N, ft)
break
except ValueError:
continue
print (N)
####exercice5
def remplace_tirets_par_des_underscores(user):
return user.replace('-', '_')
print(remplace_tirets_par_des_underscores(input("salam alikoum entrez quelque chose: ")))
#####exercice6
liste = ["tomate", "salade", "oignons", "mais", "fromages"]
print("acheter les",liste[0],"en premier")
print("acheter les",liste[-1],"en deuxième")
print(liste[2])
#####exercice7
liste1 = [["hammiche", "kamel", "47", "1972"], ["macron", "emmanuelle", "42", "1977"]]
def information(liste1):
for i in range(len(liste1)):
for j in range(len(liste1[i])):
print(liste1[i][j])
information(liste1)
####exercice8
liste = [14, 78, 417, 59, 36]
print(max(liste))
####pour aller plus loin
liste = ["kamel","pol","toto","gogol"]
longueur = len(liste)
print(longueur)
####exercice9
words = " "
taches = list()
while words != "fin":
taches.append(words)
words =input("entrer taches a realiser")
taches.pop(0)
print(taches)
#### exercice7 pour aller plus loin
liste = [['horlein', 'bruno', 40, 1979], ['gossart', 'thomas', 29, 1981], ['hammiche', 'camelia', 5, 2014], ['hammiche', 'lila', 7, 2012]]
def tableau(liste):
for i in range (len(liste)):
for j in range(len(liste[i])):
print(liste[i] [j])
tableau(liste)
######exercice9