Good luck replit python

Joined
Sep 21, 2024
Messages
2
Reaction score
0
put this in your code 1 in a billion chance
import random
print("do you want to play a game?")
if(input)("") == "yes":
print("Ok what do you want to play?")
if(input)("") == "guess the number":
print("ok")
print("guess a number between 1 and 1000000000")
number = random.randint(1,1000000000)
guess = int(input(""))
while(number!=guess) :
print("nope try again")
number = random.randint(1,1000000000)
guess = int(input(""))
else:
print("you win! the number was",number)
 
Joined
Sep 21, 2024
Messages
2
Reaction score
0
import random

print("do you want to play a game?")
if(input)("") == "yes":
print("Ok what do you want to play?")
if(input)("") == "guess the number":
print("ok")
print("guess a number between 1 and 1000000000")
number = random.randint(1,1000000000)
guess = int(input(""))
while(number!=guess) :
print("nope try again")
number = random.randint(1,1000000000)
guess = int(input(""))
else:
print("you win! the number was",number)
 
Joined
Jul 4, 2023
Messages
589
Reaction score
78
@cupcakejr090, your code is a great example of how easy Python is to learn.
Don't take offense—it's nothing personal—but isn't it somewhat pointless?
How easy is it to guess a number between 1 and 1,000,000,000?
Also, the code contains some logical errors that could affect how the game works.

BTW, corrected the logic inside the while loop to stop changing the random number after each incorrect guess.

Check this
Python:
import random

def input_():
    return input().strip().lower()

print("Do you want to play a game?")
if input_() in ["yes", "ye", "y"]:
    print("Ok, what do you want to play?")
   
    if input_() == "guess the number":
        print("Ok")
        print("Guess a number between 1 and 1,000,000,000")
        number = random.randint(1, 1000000000)

        while True:
            try:
                guess = int(input_())
                if guess == number:
                    print("You win! The number was", number)
                    break
                elif guess == 0: # Zero means exit
                    print("It's a pity you don't want to continue playing")
                    break
                elif guess > number:
                    print("The number you entered is too high")
                elif guess < number:
                    print("The number you entered is too small")
            except:
                print("Just numbers please")
    else:
        print("The currently available game is: \"guess the number\"")
else:
    print("Maybe next time!")
 
Joined
Sep 23, 2024
Messages
3
Reaction score
0
Python:
import random

def play_game():
    print("Do you want to play a game?")
    if input("").strip().lower() == "yes":
        print("Great! What game do you want to play?")
        if input("").strip().lower() == "guess the number":
            print("Alright! Guess a number between 1 and 1,000,000,000.")
            number = random.randint(1, 1000000000)
            guess = None
            
            while guess != number:
                try:
                    guess = int(input("Your guess: "))
                    if guess < number:
                        print("Higher! Try again.")
                    elif guess > number:
                        print("Lower! Try again.")
                except ValueError:
                    print("Please enter a valid number.")
                    
            print("You win! The number was", number)
    else:
        print("Maybe next time!")

play_game()
 
Joined
Sep 20, 2022
Messages
230
Reaction score
38
A number guessing game coded like that is pointless, because I can't cheat.

The computer should pick a number, print it on the screen, then ask me if it was the number I was thinking of.

If I type yes, I win, because I predicted the future.

If I type no, I win, because the computer failed to read my mind.

Now that's a game.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
474,260
Messages
2,571,039
Members
48,768
Latest member
first4landlord

Latest Threads

Top