Correction Bac Pratique Scientifique 2024
Correction Bac Pratique Scientifique 2024
Correction Bac Pratique Scientifique 2024
py
file:///C:/PySchool/3.10-32-bit/user_data/thonny/temp/thonny_vguloux4.html 1/1
02/02/2024 23:47 bac 2024 2ieme_sujet.py
file:///C:/PySchool/3.10-32-bit/user_data/thonny/temp/thonny_70axae_7.html 1/1
02/02/2024 23:47 bac 2024 3ieme sceance.py
1 def miroir(mot):
2 lm=len(mot)
3 chm=""
4 for i in range(lm):
5 chm=chm+mot[-1-i]
6 return chm
7
8 def verifcar(ch):
9 test=True
10 i=0
11 while((i<len(ch))and(test==True)):
12 if(("a"<=ch[i]<="z")or(ch[i]==" ")):
13 i=i+1
14 else:
15 test=False
16 return test
17
18 def verifesp(ch):
19 p_esp=ch.find(" ")
20 if( ch[p_esp+1]==" "):
21 print("entre 2 mots un seul espace est autorisé")
22 return False
23 else:
24 return True
25
26 def verif(ch):
27 lg=len(ch)
28 if((lg==0)or(lg>50)or (verifcar(ch)==False) or(verifesp(ch)==False)):
29 return False
30 else:
31 return True
32 valide=False
33 while(valide==False):
34 ch=input("saisir une chaine:")
35 valide=(verif(ch))
36 p=ch.find(" ")
37 chinv=""
38 while(p!=-1):
39 chr=ch[0:p]
40 chinv=chinv+" "+miroir(chr)
41 ch=ch[p+1:len(ch)]
42 p=ch.find(" ")
43 chr=ch
44 chinv=chinv+" "+miroir(chr)
45 print("la chaine inversée:",chinv)
file:///C:/PySchool/3.10-32-bit/user_data/thonny/temp/thonny_ts8lhmk6.html 1/1
02/02/2024 23:45 bac 2024 4ieme_sujet.py *
file:///C:/PySchool/3.10-32-bit/user_data/thonny/temp/thonny_17nhl1xg.html 2/2
02/02/2024 23:46 bac 2024 5ieme_sujet.py *
1 def verifcar(ch):
2 test=True
3 i=0
4 while((i<len(ch))and(test==True)):
5 if("a"<=ch[i]<="z"):
6 i=i+1
7 else:
8 test=False
9 return test
10 def verif(ch):
11 lg=len(ch)
12 if((lg==0)or(lg>30)or (verifcar(ch)==False)):
13 return False
14 else:
15 return True
16 def saisie():
17 ch=input("donner une chaine:")
18 while not (verif(ch)):
19 ch=input("donner une chaine:")
20 return ch
21 def chercher(x,y):
22 ch=""
23 for i in range(len(x)):
24 for j in range(len(y)):
25 if(x[i]==y[j]):
26 p=ch.find(x[i])
27 if(p==-1):
28 ch=ch+x[i]
29 print(ch)
30 #programme principale
31 ch1=saisie()
32 ch2=saisie()
33 chercher(ch1,ch2)
34
file:///C:/PySchool/3.10-32-bit/user_data/thonny/temp/thonny_apo7aueo.html 1/1