-
Notifications
You must be signed in to change notification settings - Fork 0
/
partie4.py
169 lines (137 loc) · 3.46 KB
/
partie4.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
## 1\.Exercice 1 : Un échiquier ma logique a peaufinner.
#i = "# "
#b = " #"
#echiquier = ""
#while len(echiquier) <= 73:
# echiquier.append(b)
#if echiquier.append(b)
# echiquier.append(i)
#if len(echiquier) == 73:
# print(echiquier)
#Exercice 1 fait
c = "# "
b = " #"
echiquier =""
for i in range(0, 8):
if (i % 2 == 0):
echiquier += b *8 + "\n"
else:
echiquier += c *8 + "\n"
print(echiquier)
###exercice 2:
code=[0, 0, 0, 0]
a= 0
b= 0
c= 0
d= 0
e= "------------"
for i in range(0,4) :
code[i] = 1
a = code[0]
b = code[1]
c = code[2]
d = code[3]
print("{}\n{}\n{}\n{}\n{}".format(a,b,c,d,e))
code[i]= 0
###exercice 3:
from math import *
def pair(panier):
if panier %2 == 0:
print("True")
else:
print("False")
panier = round(63.4)
print(panier)
print(pair(panier))
###exercice 4:
print("insert number ")
chiffre= int(input())
print("le factorielle de ", chiffre, "=")
facto = 1
while chiffre != 1:
print("*",chiffre, end='' )
facto *= chiffre
chiffre -= 1
print("\n", facto)
###exercice 5:
def re(text):
text = text.replace('-', '\_')
return(text)
texti="oulou - - - - - louuuu"
print(re(texti))
### exercice 6
tableau = ["botte", "glasse", "ruta", "hotte","op"]
print("merci d'acheté", tableau[0],"et", tableau[-1])
print("merci d'acheté", max(tableau))
###exercice 7
#import json
#def personne(personnage,info ):
# values = []
# with open("personnage") as f:
# data = json.load(f)
# for entry in data:
# values.append(entry[2])
# return values
#print(personne([2],info))
character = [
["kassama","fally","28","1990"],
["kazama","jin","33","1986"],
["","","",""]
]
if input("choisi le perso que tu veux 1,2 ou 3 ") == "1":
print(character[0],)
if input("choisi le perso que tu veux 1,2 ou 3 ") == "2":
print(character[1],)
if input("choisi le perso que tu veux 1,2 ou 3 ") == "3":
print(character[2],)
perso=["kassama", "fally", "28", "1990"]
perso2=["ouloulou","tmsoule","56", "1936"]
nom = input("nom? ")
prenom= input("prenom? ")
age = input("age? ")
date_de_naissance= input("date de naissance ?")
perso3=[nom, prenom, age, date_de_naissance]
character=[perso,perso2,perso3]
off = ""
print("perso differents")
while off != "stop":
off = input("tu veux arreter?")
if input("tapez 1 pour le premier perso") == "1":
print(perso[0], perso[1],"a",perso[2], "et est néé en",perso[3])
if input("tapez un 2 pour le deuxieme perso") == "2":
print(perso2[0], perso2[1],"a",perso2[2], "et est néé en",perso2[3])
if input("tapez 3 pour le troisieme perso") == "3":
print(perso3[0], perso3[1],"a",perso3[2], "et est néé en",perso3[3])
else :
print("merci de de choisir 1 ou 2 ou 3")
if input() == "stop":
print("bye bye")
###exercice 8
grille = ["nsdvnsl","hsdljshg","jnskjn", 4,2, 1]
listtr = []
listint = []
longest = ""
def table(tab):
listtr = list()
listint = list()
for element in grille :
if isinstance((element),str):
listtr.append(element)
if isinstance((element),int):
listint.append(element)
table(grille)
for i in range(len(listtr)):
if len(listtr[i]) > len(longest):
longest = listtr[i]
if len(longest) > max(listint):
print(longest)
else:
print(max(listint))
#### exercice 9
todolist = []
task = ""
while task != "stop":
task = input("met ce que tu veux pardi !!")
todolist.append(task)
for task in todolist :
print(task)