snt_jeu2.py

Created by jeromemunier

Created on July 02, 2020

442 Bytes

Jouer contre la calculatrice


def saisie():
  choix=int(input("Devine le nombre choisi \n  par la machine (0-99) : "))
  return(choix)

def compare(a,b):
  if a<b:
    print("trop petit")
  else:
    print("trop grand")

from random import randint
compteur=0
machine=randint(1,99)
print(machine)
joueur=saisie()
while joueur!=machine:
  compare(joueur,machine)
  joueur=saisie()
  compteur=compteur+1
print("Bravo, tu as trouve \n en ", compteur, "coups.")

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.