Python Random Number | Faster and easier now in 1 min

Python Random Number, Generate random number from 1 to 100

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
number = random.randint(1, 100)
number = random.randint(1, 100)
number = random.randint(1, 100)

Provide the number through input

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
guess = int(input("Guess the number between 1 and 100: "))
guess = int(input("Guess the number between 1 and 100: "))
guess = int(input("Guess the number between 1 and 100: "))

Now try to compare the given number

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
if guess < number:
print("Too low")
guess = int(input("Guess again: "))
if guess < number: print("Too low") guess = int(input("Guess again: "))
if guess < number:
    print("Too low")
    guess = int(input("Guess again: "))

if the number is greater than guess

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
elif guess > number:
print("Too high")
guess = int(input("Guess again: "))
elif guess > number: print("Too high") guess = int(input("Guess again: "))
elif guess > number:
        print("Too high")
        guess = int(input("Guess again: "))

Python Random Number

Plain text
Copy to clipboard
Open code in new window
EnlighterJS 3 Syntax Highlighter
import random
number = random.randint(1, 100)
guess = int(input("Guess the number between 1 and 100: "))
while guess != number:
if guess < number:
print("Too low")
guess = int(input("Guess again: "))
elif guess > number:
print("Too high")
guess = int(input("Guess again: "))
print("Congratulations! You guessed the number correctly!")
import random number = random.randint(1, 100) guess = int(input("Guess the number between 1 and 100: ")) while guess != number: if guess < number: print("Too low") guess = int(input("Guess again: ")) elif guess > number: print("Too high") guess = int(input("Guess again: ")) print("Congratulations! You guessed the number correctly!")
import random

number = random.randint(1, 100)
guess = int(input("Guess the number between 1 and 100: "))

while guess != number:
    if guess < number:
        print("Too low")
        guess = int(input("Guess again: "))
    elif guess > number:
        print("Too high")
        guess = int(input("Guess again: "))

print("Congratulations! You guessed the number correctly!")