Inscription / Connexion Nouveau Sujet
Niveau première
Partager :

Exercice aléatoire à partir d'un algorithme

Posté par
Auryrsseau
09-11-19 à 14:24

Bonjour,
J'ai un dm maison à faire pour la semaine prochaine et je n'arrive pas à un exercice.

Celui-ci se présente sous cette forme:
Import random
a= random.randint (1,5)
If a==1
        B= random.randit (1,3)
        If b==1:
                 Print("Rouge")
        Else:
                 Print("orange")
Else:
         B=random.randit(1,12)
         If b>8:
                  Print("rouge")
         Else:
                  Print("orange")


Merci d'avance pour votre aide🤓

Posté par
Auryrsseau
re : Exercice aléatoire à partir d'un algorithme 09-11-19 à 14:36

Jai oublie la question
Les événements "a=1" et "Le programme affiche rouge" sont ils indépendants? Justifier.(on pourra s'aider d'un arbre)

Posté par
flight
re : Exercice aléatoire à partir d'un algorithme 09-11-19 à 17:02

salut

de ce que je comprend  

on choisi un entier a entre 1 et 5
si a = 1
    on choisit un entier b entre  1 et 3
        si b = 1:
                 on affiche rouge
       sinon
                 on affiche orange
      fin si
sinon
        on choisit un entier b entre 1 et 12
        si  b>8
                  on affiche rouge
            sinon
                on affiche orange
       fin du si

fin du si



Vous devez être membre accéder à ce service...

Pas encore inscrit ?

1 compte par personne, multi-compte interdit !

Ou identifiez-vous :


Rester sur la page

Inscription gratuite

Fiches en rapport

parmi 1675 fiches de maths

Désolé, votre version d'Internet Explorer est plus que périmée ! Merci de le mettre à jour ou de télécharger Firefox ou Google Chrome pour utiliser le site. Votre ordinateur vous remerciera !