#! /usr/bin/env python # -*- coding: utf-8 -*- # prog01.txt # http://www.linux-azur.org/~ramix/python/debuter_avec_Python/prog06.txt # converts euros to french francs or the opposite ########################################################### def print_options(): print ("=== Options :===============") print (" 'p' print options") print (" 'f' convert from francs") print (" 'e' convert from euros") print (" 'q' quit the program") def franc_to_euro(valeur): return 0.15 * valeur def euro_to_franc(valeur): return 6.56 * valeur choice = "p" while choice != "q": if choice == "f": somme = input("Somme en Francs :") print ("Somme en Euros :",franc_to_euro(somme)) elif choice == "e": somme = input("Somme en Euros :") print ("Somme en Francs :",euro_to_franc(somme)) elif choice != "q": print_options() else : pass # ou continue choice = raw_input("option:") # choice = input("option:") pour Python 3.3 else: print ('''Joel c'est vraiment facile avec PYTHON ... Merci pour tout et en particulier pour le Guide Python OREILLY à la fois précis, concis et pas cher du tout ;-) ''') # Exemple d'execution : # python prog01.txt # === Options :==================== # 'p' print options # 'f' convert from francs" # 'e' convert from euros" # 'q' quit the program # option:f # Somme en francs : 100 # Somme en Euros : 15 # option:e # Somme en Euros : 10 # Somme en Francs : 65.6 # option:q