Procede en base 4 a divers calculs. Puis statistique des chiffres du numero etudiant.
def base(num,b=8): if num == 0: return "" else: return base(num//b,b) + str(num%b) def calculs(num): L=[(num//10**k)%10 for k in range(7)] S=[sum(1 for k in L if k==l) for l in range(10)] L=[k for k in L if k<4] L.reverse() l=len(L) [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q]=[L[k%l] for k in range(17)] print("ABC+DEF=",base(A*16+B*4+C,4),'+',base(D*16+E*4+F,4),'=', # base(A*16+B*4+C+D*16+E*4+F,4),'\n= base X:', A*16+B*4+C,'+', D*16+E*4+F,'=',# A*16+B*4+C+D*16+E*4+F) print("GHI-JK=" ,base(G*16+H*4+I,4),'-',base(J*4+K,4),'=', # base(G*16+H*4+I-J*4-K,4),'\n= base X:', G*16+H*4+I,'-', J*4+K,'=', # G*16+H*4+I-J*4-K) print("LMN*2=" , base((L*16+M*4+N),4),'*2=', base((L*16+M*4+N)*2,4),# '\n= base X:', (L*16+M*4+N),'*2=', (L*16+M*4+N)*2) print("OPQ÷3=" ,base(O*16+P*4+Q,4),'÷3 q=', base((O*16+P*4+Q)//3,4),# '\nbase X:', (O*16+P*4+Q),'÷3 q=', (O*16+P*4+Q)//3, ', r=', (O*16+P*4+Q)%3) # print("Statistique des chiffres:") print([k for k in range(10)]) print(S) Sc=[sum(k for k in S[:(l+1)]) for l in range(10)] print(Sc) print("Médiane: ",[k for k in range(10) if Sc[k]>=4][0]," Moyenne: ",# sum(k*S[k] for k in range(10))/7) return [A,B,C,D,E,F,G,H,I,J,K,L,M,N,O,P,Q] calculs(int(input("Entrez votre numéro \n d'étudiant·e : ")))