Skip to content

[THIS IS SPAM] Treinando Phyton , fazendo jogo de advinhação basico #4142

Description

@AqyyA

import random

def exibir_ranking (ranking):
print("\n--- Ranking de Pontuação ---")
if not ranking:
print("Nenhum jogador registrado.")
else:
for i, pontos in enumerate(ranking[:5],1):
print(f"{i}º lugar: {pontos} tentativas")
print("-----------------------------")

def jogar():
ranking = []
while True :
numero_secreto = random.randint(1, 100)
tentativas = 0
acertou = False

    print ("-----------------------------")
    print("Bem-vindo ao jogo de adivinhação!")
    print("Tente adivinhar o número secreto entre 1 e 100.")
    print ("-----------------------------")
    while not acertou:
        try:
            chute = int(input("digite seu chute : "))
            tentativas += 1
            if chute < numero_secreto:
                print("Tente um número maior.")
            elif chute > numero_secreto:
                print("Tente um número menor.")
            else:
                acertou = True      
                print(f" Parabens Voce acertou o numero secreto em {tentativas} tentativas.")
                ranking.append(tentativas)
        except ValueError:
            print("digite um numero valido.") 

    exibir_ranking(ranking)
    jogar_novamente = input("Deseja jogar novamente? (s/n): ")          
    if jogar_novamente.lower() != 's':
        print("Obrigado por jogar! Até a próxima!")
        break

if name == "main": jogar()

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions