Sujets Infos
Sujets Infos
INFOS
SUJET1:
from numpy import array
def verif(ch):
test=True
i=0
while (i<len(ch) and test==True):
if "A"<=ch[i]<="Z":
i=i+1
else:
test=False
return(test)
def mot_princ():
ch=input("donner une mot")
while not (len(ch)!=0 and verif(ch)):
ch=input("donner un mot")
return(ch)
k=mot_princ()
taille()
T=array([str]*N)
remp(T,N,k)
aff(T,N,k)
SUJET2:
from numpy import array
def taille():
global N
N=int(input("donner N: "))
while not (5<=N<=25):
N=int(input("donner N "))
def verif(c):
test=True
i=0
while (i<len(c) and test==True):
if ("A"<=c[i]<="Z" or c[i]==" "):
i=i+1
else:
test=False
return test
def remp(T,N):
for i in range(N):
T[i]=input("donner T["+str(i)+"]")
while not(verif(T[i])):
T[i]=input("donner T["+str(i)+"]")
def voy(ch):
s=0
for i in range(len(ch)):
if ch[i] in ["A","O","I","Y","E","U"]:
s=s+1
return(s)
def aff(T,N):
for i in range(N):
if voy(T[i])==5:
print(T[i])
taille()
T=array([str]*N)
remp(T,N)
aff(T,N)
SUJET3:
def saisir():
global m,n
m=int(input("donner m: "))
n=int(input("donner n: "))
while not (100<=n<m):
m=int(input("donner m: "))
n=int(input("donner n: "))
def Harshad (x):
s=0
ch=str(x)
test=False
for i in range (len(ch)):
s=s+int(ch[i])
if x%s==0:
test=True
return test
def premier(y):
c=str(y)
i=2
quest=True
while (i<y and quest==True):
if y%i==0:
quest=False
else:
i=i+1
return quest
def aff(n,m):
for i in range (n,m+1):
if (premier(i-1) and Harshad(i)):
print(f'{i} car {i} est harshad et son precedeur {i-1} est un nombre premier')
saisir()
aff(n,m)