Deutsch   English   Français   Italiano  
<spal1e$1t4u$1@gioia.aioe.org>

View for Bookmarking (what is this?)
Look up another Usenet article

Path: ...!weretis.net!feeder6.news.weretis.net!feeder8.news.weretis.net!news.uzoreto.com!aioe.org!FdrTMw7+RJa5kGNwdwd/KQ.user.46.165.242.91.POSTED!not-for-mail
From: Dominique <zzz@aol.com.invalid>
Newsgroups: fr.comp.lang.python
Subject: Triangle de Pascal.
Date: Tue, 14 Dec 2021 18:42:06 +0100
Organization: Aioe.org NNTP Server
Message-ID: <spal1e$1t4u$1@gioia.aioe.org>
Mime-Version: 1.0
Content-Type: text/plain; charset=UTF-8; format=flowed
Content-Transfer-Encoding: 8bit
Injection-Info: gioia.aioe.org; logging-data="62622"; posting-host="FdrTMw7+RJa5kGNwdwd/KQ.user.gioia.aioe.org"; mail-complaints-to="abuse@aioe.org";
User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101
 Thunderbird/91.4.0
X-Notice: Filtered by postfilter v. 0.9.2
Content-Language: fr
Bytes: 2844
Lines: 85

Bonsoir,

J'ai bidouillé un script qui calcule (j'ai commenté la ligne affichant 
les résultat chiffrés : #print(rep)) un triangle de Pascal, puis qui 
fait la sortie sympa avec un symbole pour les valeurs paires et un autre 
pour les valeurs impaires :

(Ma question est tout en bas...)

------------------------------------------
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
"""
Created on Sat Dec 11 17:43:18 2021

@author: le-voileux
"""
import copy

lignes=int(input('Nombre de lignes '))
lignes+=1
num1=1

trig=[[0]*(2*lignes+3)]*lignes#Je crée mon tableau
mid=int(len(trig[0])/2)#Je calcule l'index de la cellule du milieu
trig[0][mid]=num1
for i in range(0,len(trig)-1):
     trig[i]=copy.deepcopy(trig[i])#Je dissocie toutes les itérations de 
trig afin que tous les id soient différents
trig[0][mid]=num1#Je place au milieu le nombre de départ

for i in range(1,lignes):#Je construis mon triangle de Pascal
     for j in range(1,len(trig[0])-1):
         trig[i][j]=trig[i-1][j-1]+trig[i-1][j+1]


#Je construits le triangle de chiffres
for i in trig:
     rep=''
     for j in i:
         if j==0:
             j=' '
         else:
             j=str(j)

         rep+=' '*int(4-len(j))+j
     #print(rep)


#Je construits le triangle de pictogrammes


for i in trig:
     l=''
     rep=''


     for j in i:
         if j!=0 and j%2==0:
             l=chr(0x2b21)
             #l=chr(0x25bc)


         if j!=0 and j%2!=0:
             l=chr(0x2b22)
             #l=chr(0x25cb)


         if j==0:
             l=' '

         rep+=l

     print(rep)

-----------------------------------------------

Comment me faudrait-il m'y prendre pour récupérer cette sortie graphique 
sous forme d'une image jpeg ou autre chose ?

Merci et bonne soirée à tous,

-- 
Dominique
Courriel : dominique point sextant ate orange en France
Esto quod es