plus_ou_moins.py

Created by alexandrebret-84

Created on November 10, 2020

1.45 KB

Il faut deviner un nombre entre 1 et 1000.


from random import randint

def clear(nb):
    print("\n"*nb)


def jeu(a,b):
    if b == 0:
        return True
    elif a < b:
        clear(0)
        print("C'est moins !")
        return True
    elif a > b:
        clear(0)
        print("C'est plus !")
        return True
    elif a == b:
        clear(0)
        print("BRAVO !")
        clear(0)
        encore = float(input("Voulez vous recommencer ?\n1 = oui, 2 = non : "))
        if encore == 1:
            clear(9)
            jouer()
        else:
            menu()
    


def jouer():
    ordi = randint(1,1000)
    joueur = 0
    while jeu(ordi,joueur):
        clear(1)
        joueur = int(input("Ecrivez un nombre : "))
        

def regle():
    clear(5)
    print("Le but du jeu est de trouver\nle nombre choisi aleatoirement\nentre 1 et 1000")
    clear(1)
    go_menu = float(input("Ecrivez un nombre pour\nretourner au menu : "))
    if go_menu == 1:
        menu()
    else:
        menu()


def menu():
    clear(3)
    print("        ______________")
    print("       |              |")
    print("       |     PLUS     |")
    print("       |      OU      |")
    print("       |     MOINS    |")
    print("       |______________|")
    print("\n1 - Regle")
    print("2 - Jouer")
    clear(1)
    choix = float(input("Indiquez votre choix : "))
    if choix == 1:
        regle()
    elif choix == 2:
        clear(9)
        jouer()
    else:
        menu()
        
menu()

During your visit to our site, NumWorks needs to install "cookies" or use other technologies to collect data about you in order to:

With the exception of Cookies essential to the operation of the site, NumWorks leaves you the choice: you can accept Cookies for audience measurement by clicking on the "Accept and continue" button, or refuse these Cookies by clicking on the "Continue without accepting" button or by continuing your browsing. You can update your choice at any time by clicking on the link "Manage my cookies" at the bottom of the page. For more information, please consult our cookies policy.