PYTHON LANGUAGE



Exercice 2.1


Enter the following program into the code window and test it:

Tester le programme ci-dessous:

# la variable answer prendra la valeur saisie au clavier

answer = input("what is the color of Henry IV's white horse?")

# si la variable answer est égale (==)  à white:

if answer == 'white':

    print(" good answer!")

    print("bye bye")

# sinon si la variable réponse est égale à White

elif answer == 'White':

    print(" good answer!")

    print("bye bye")

# sinon  

else:

    print("Sorry this is not the expected answer")



Exercice 2.2


with the help of the previous program

Selon le même principe que le programme ci-dessus:


Write a program that asks the user "what is your favorite color?"

if the chosen color is equal to 'red' or if the chosen color is equal to 'orange', display "you have chosen the color of passion"

otherwise if the chosen color is 'green', display "you have chosen the color of hope"

otherwise if the chosen color is 'blue', display "you have chosen the color of confidence"

otherwise display "thanks for your response


Ecrire un programme qui demande à l'utilisateur "quelle est ta couleur préférée?"

si la couleur choisie est égale à 'rouge' ou si la couleur choisie est égale à 'orange', afficher "tu as choisi la couleur de la passion"

sinon si la couleur choisie est 'vert', afficher "tu as choisi la couleur de l'espoir"  

sinon si la couleur choisie est 'bleu', afficher "tu as choisi la couleur de la confiance"

sinon afficher "merci pour ta réponse"


Vous pouvez passer au chapitre suivant "Loops"


Créé avec HelpNDoc Personal Edition: Outils facile d'utilisation pour créer des aides HTML et des sites web