Topic de Baizeur13 :

Un khey pour cette exo Python? Urgent

  • 1
Svp les khey :oui:
j'ai 5 exercices à faire avant 13h
je vous demande juste de rédiger celui ci https://image.noelshack.com/fichiers/2021/02/5/1610706662-exercice3pdf.png
Merci beaucoup si y a un fréro qui peut me le faire, je suis débordé svp :merci:
import time
import numpy as np

N = np.random.randint(100, 201) 
TEMPS = 2
t_start = time.clock()
while (time.clock() - t_start) < TEMPS * 60:
    a = input("Tu choisis quel entier ma gueule issou la chancla ?")
    if a == N:
       break
print("Nombre à deviner: ", N)
print("Temps écoulé: ", time.clock() - t_start)

De rien cléyou https://image.noelshack.com/fichiers/2020/23/2/1591098807-ahi-gauche.png

Le 15 janvier 2021 à 11:37:14 AzaPlop a écrit :
<code>import time
import numpy as np

N = np.random.randint(100, 201)
TEMPS = 2
t_start = time.clock()
while (time.clock() - t_start) < TEMPS * 60:
a = input("Tu choisis quel entier ma gueule issou la chancla ?")
if a == N:
break
print("Nombre à deviner: ", N)
print("Temps écoulé: ", time.clock() - t_start)
</code>
De rien cléyou https://image.noelshack.com/fichiers/2020/23/2/1591098807-ahi-gauche.png

quel homme

merci kheyou :oui: t'es un bon

Teste qu'il fonctionne bien quand même, j'ai fait ça à l'arrache https://image.noelshack.com/fichiers/2020/23/2/1591098807-ahi-gauche.png

Faut aussi que tu fasses la version où c'est une fonction et on passe le nombre et le temps en argument https://image.noelshack.com/fichiers/2017/39/3/1506524542-ruth-perplexev2.png

# https://www.jeuxvideo.com/forums/42-51-65433752-1-0-1-0-un-khey-pour-cette-exo-python-urgent.htm
# the_guesser_time.py

import random
import time

def the_guesser(number: int, timer: int) -> None:
    """The Guesser: Devinez un nombre entre 100 et 200.

    Args:
        N (int): Nombre à deviner
        T (int): Temps accordé en minutes.
    """    
    
    # N = random.randint(100, 200)
    N = number
    # print(N)  # Debugging

    TEMPS = timer  # temps accordé en minutes
    START = time.time()

    user_choice = int(input("Devinez un nombre entre 100 et 200: "))

    while time.time() - START < (TEMPS * 60):
        if user_choice > N:
            print('plus petit')
        elif user_choice < N:
            print('plus grand')
        elif user_choice == N:
            print(f"Bravo, le nombre à deviner était {N}.")
            break

        user_choice = int(input("Devinez un nombre entre 100 et 200: "))
            
    timing = time.time() - START
    print(f"Timing: {round(timing, 2)}s.")

if __name__ == "__main__":
    the_guesser(151, 2)  # On doit deviner le nombre 151 en moins de 2 minutes.
  • 1

Données du topic

Auteur
Baizeur13
Date de création
15 janvier 2021 à 11:31:10
Nb. messages archivés
7
Nb. messages JVC
7
En ligne sur JvArchive 155