IdentifiantMot de passe
Loading...
Mot de passe oublié ?Je m'inscris ! (gratuit)
Navigation

Inscrivez-vous gratuitement
pour pouvoir participer, suivre les réponses en temps réel, voter pour les messages, poser vos propres questions et recevoir la newsletter

Python Discussion :

Lignes sautées entre deux retour de fonctions


Sujet :

Python

  1. #1
    Nouveau Candidat au Club
    Homme Profil pro
    Étudiant
    Inscrit en
    Octobre 2017
    Messages
    1
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Hérault (Languedoc Roussillon)

    Informations professionnelles :
    Activité : Étudiant

    Informations forums :
    Inscription : Octobre 2017
    Messages : 1
    Points : 1
    Points
    1
    Par défaut Lignes sautées entre deux retour de fonctions
    Mon code est le suivant :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    16
    17
    18
    19
    20
    21
    22
    23
    24
    25
    26
    27
    28
    29
    30
    31
    32
    33
    34
    35
    36
    37
    38
    39
    40
    41
    42
    43
    44
    45
    46
    47
    48
    49
    50
    51
    52
    53
    54
    55
    56
    57
    58
    59
    60
    61
    62
    63
    64
    65
    66
    67
    68
    69
    70
    71
    72
    73
    74
    75
    76
    77
    78
    79
    80
    81
    82
    83
    84
    85
    86
    87
    88
    89
    90
    91
    92
    93
    94
    95
    96
    97
    98
    99
    100
    101
    102
    103
    def get_birthday():
        bd =int(input("Tell me, what day of the month were you born on: "))
        return bd
     
    def get_today():
        date=int(input('Tell me, what day of the month is it today: '))
        return date
     
     
    def get_birthmonth():
        bm=int(input("I need one last piece of information. Tell me, what month were you born in: "))
        return bm
     
    def likes_spicy_food():
        print("One more question before we begin.")
        lsf=int(input("Do you like spicy food? (1 = yes, 2 = no) "))
        if lsf == 1 :
            return True
        if lsf == 2 :
            return False
     
    def read_lifeline(date, bd, lsf):
        print('I will now read your lifeline.')
        if lsf is True and bd%3==0:
            print ("You have a long, deep line. Your life will be filled with health and balance.")
        elif lsf is True and date%4==0 or date%5==0:
            print("You have a short, deep line. You possess remarkable fortitude.")
        elif lsf is True and bd%3 !=0 and date%4 !=0  and date%5 !=0 :
            print("A dark cloud passes over my inner eye.")
        elif lsf is False :
            print("Your line is forked and branching. Interesting events await you.")
     
    def read_heartline(date, gb):
        print('I will now read your heartline.')
        heartline = (date - gb)
        if heartline == 0:
            print('Your heartline is the perfect example of long. You are filled with warmth and love.')
     
        elif abs(heartline) > 10 :
            print("You have a faint line. You will need to work to stay present emotionally.")
     
        else :
            print("The deepness of your heartline will cause trouble if you are not aware.")
     
    def read_headline(bd,bm):
        print('I will now read your headline')
        if bd == 15 and bm == 3:
            print("I'm afraid the crosses that I see here cannot be good.")
        elif bd == bm :
            print("The deep and wavy line here shows excellent memory but not without conflict.")                
        elif bd%2 ==0 and bm%2 ==0 or bd%2 !=0 and bm%2 !=0:
            print("The branched and upwards line here shows big dreams and self awareness.")          
        else:
            print("The branched line here shows many events unknown to even the spirits.")
     
    def welcome():
        print("Welcome to Madame Maxine's Fortune Palace.")
        print("Here, we gaze deeply into your soul and find the secrets that only destiny has heretofore known!")
     
    def goodbye():
        print()
        print("These insights into your future are not to be enjoyed or dreaded, they simply come to pass.")
        print("Good day.")
     
    def bad_day():
        print()
        print("Today is a bad day for fortune telling.")
     
    def line_1():
        print("The power of my inner eye clouds my ability to keep track of mundane things like the date.")
     
    def line_3():
        print("Numerology is vitally important to fortune telling.")
     
     
    def main():
     
        welcome()
        print()
     
        line_1()
        date = get_today()
        line_3()
        bd= get_birthday()
     
     
        if 0<date<=9 :
            lsf= likes_spicy_food()
            read_lifeline(date,bd,lsf)
     
        if 9<date<=19 :
            read_heartline(date,bd)
     
        if 19<date<=29 :
            bm = get_birthmonth()
            read_headline(bd,bm)
     
        if date == 30 or date == 31:
            bad_day()
     
        goodbye()
     
    main()

    J'obtiens ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    Welcome to Madame Maxine's Fortune Palace.
    Here, we gaze deeply into your soul and find the secrets that only destiny has heretofore known!
     
    The power of my inner eye clouds my ability to keep track of mundane things like the date.
     
    Tell me, what day of the month is it today: 31
    Numerology is vitally important to fortune telling.
     
    Tell me, what day of the month were you born on: 11
     
    Today is a bad day for fortune telling.
     
    These insights into your future are not to be enjoyed or dreaded, they simply come to pass.
    Good day.

    Je dois obtenir ça :
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    4
    5
    6
    7
    8
    9
    10
    11
    12
    13
    14
    15
    Welcome to Madame Maxine's Fortune Palace.
    Here, we gaze deeply into your soul and find the
    secrets that only destiny has heretofore known!
     
    The power of my inner eye clouds my ability to keep
    track of mundane things like the date.
    Tell me, what day of the month is it today: 31
    Numerology is vitally important to fortune telling.
    Tell me, what day of the month were you born on: 11
     
    Today is a bad day for fortune telling.
     
    These insights into your future are not to be enjoyed or dreaded,
    they simply come to pass.
    Good day.

    -------
    Quelqu'un a une idée pour supprimer ces lignes sautées en trop ?

  2. #2
    Membre averti Avatar de zancrows
    Homme Profil pro
    Étudiant
    Inscrit en
    Décembre 2016
    Messages
    155
    Détails du profil
    Informations personnelles :
    Sexe : Homme
    Localisation : France, Côtes d'Armor (Bretagne)

    Informations professionnelles :
    Activité : Étudiant
    Secteur : Industrie

    Informations forums :
    Inscription : Décembre 2016
    Messages : 155
    Points : 346
    Points
    346
    Par défaut
    Salut, tu as pas besoin de faire:
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    print()
    print('bonjour')
    la méthode print() à un argument 'end' qui est pas défaut égale à '\n'

  3. #3
    Expert éminent Avatar de BufferBob
    Profil pro
    responsable R&D vidage de truites
    Inscrit en
    Novembre 2010
    Messages
    3 035
    Détails du profil
    Informations personnelles :
    Localisation : France

    Informations professionnelles :
    Activité : responsable R&D vidage de truites

    Informations forums :
    Inscription : Novembre 2010
    Messages : 3 035
    Points : 8 400
    Points
    8 400
    Par défaut
    salut,

    Citation Envoyé par (bs34) Voir le message
    Mon code est le suivant : (...) J'obtiens ça : (...) Je dois obtenir ça :
    n'hésite pas à décorer ton bon de commande avec des formules de politesse basiques comme bonjour/svp/merci, voire des phrases avec sujet-verbe-complément

    sinon en gros "faut faire ça :"
    Code : Sélectionner tout - Visualiser dans une fenêtre à part
    1
    2
    3
    >>> print("good\nbye")
    good
    bye

Discussions similaires

  1. Problème de ligne vide entre deux instructions
    Par korian dans le forum PL/SQL
    Réponses: 2
    Dernier message: 25/11/2010, 09h28
  2. Réponses: 49
    Dernier message: 26/05/2010, 21h58
  3. [XL-2003] difference entre deux nombres en fonction d'une date
    Par revemane dans le forum Macros et VBA Excel
    Réponses: 15
    Dernier message: 11/06/2009, 10h26
  4. Réponses: 5
    Dernier message: 01/12/2008, 14h20
  5. Détecter les lignes identiques entre deux matrices
    Par totovich dans le forum MATLAB
    Réponses: 5
    Dernier message: 17/04/2007, 09h42

Partager

Partager
  • Envoyer la discussion sur Viadeo
  • Envoyer la discussion sur Twitter
  • Envoyer la discussion sur Google
  • Envoyer la discussion sur Facebook
  • Envoyer la discussion sur Digg
  • Envoyer la discussion sur Delicious
  • Envoyer la discussion sur MySpace
  • Envoyer la discussion sur Yahoo