J'aimerai faire matrix en python mais je n'y arrive pas.

Résolu/Fermé
Multi73 Messages postés 88 Date d'inscription dimanche 13 septembre 2020 Statut Membre Dernière intervention 4 mai 2022 - 3 juin 2021 à 11:28
Multi73 Messages postés 88 Date d'inscription dimanche 13 septembre 2020 Statut Membre Dernière intervention 4 mai 2022 - 4 juin 2021 à 17:31
Bonjour,
J'aimerai faire matrix en python mais je n'y arrive pas.
Voici mon programme.
import time
import os.system
os.system("color a")
x=1
while x = 1
    print(%random%%random%%random%%random%%random%%random%%random%%random%)


Pouvez vous m'aidez svp ?

2 réponses

jee pee Messages postés 39650 Date d'inscription mercredi 2 mai 2007 Statut Modérateur Dernière intervention 26 avril 2024 9 238
Modifié le 3 juin 2021 à 12:35
Bonjour,

Tu devrais reprendre le cours Python au début ;-)

x=1 affectation
x==1 test égalité

puis un bloc (if,while, def ...) a une ligne titre qui se termine par : donc
while x==1:


puis pas besoin d'une variable x, on peut faire une boucle infinie :
while True:


%random% c'est une variable MSDOS/ligne de commande, dans Python ce sera :

import os
import random
os.system("color a")
while True:
    print(random.randint(0,9),random.randint(0,9),random.randint(0,9),random.randint(0,9),random.randint(0,9),random.randint(0,9))


ou un truc batard
import os
import random
os.system("color a")
while True:
    os.system('echo %random% %random% %random% %random% %random% %random% %random% %random%')


mais alors autant faire du msdos, pas du python
0
Multi73 Messages postés 88 Date d'inscription dimanche 13 septembre 2020 Statut Membre Dernière intervention 4 mai 2022 2
4 juin 2021 à 17:31
Ok merci beaucoup !
0