Python Program

Python Random Number | Faster and easier now in 1 min

Python Random Number, Generate random number from 1 to 100

number = random.randint(1, 100)

Provide the number through input

guess = int(input("Guess the number between 1 and 100: "))

Now try to compare the given number

if guess < number:
    print("Too low")
    guess = int(input("Guess again: "))

if the number is greater than guess

elif guess > number:
        print("Too high")
        guess = int(input("Guess again: "))

Python Random Number

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!")
Abhishek

Share
Published by
Abhishek

Recent Posts

HTML: The Evolution and Power of Unleashed Web Language and Modern too

IntroductionInitial StagesEvolutionChallenging Other LanguagesCurrent TrendsAI and HTMLConclusion Introduction HTML, or HyperText Markup Language, is the…

2 months ago

Increase in 80C in Budget 2024 ?

Increase in 80CDemands and Discussions: Increase in 80C Section 80C of the Income Tax Act…

2 months ago

ChatGPT 4o Unleashing the Power of GPT A Comprehensive Guide

IntroductionWhat is ChatGPT-4?Key Features of ChatGPT-4Enhanced Natural Language UnderstandingImproved Response GenerationVersatilityApplications of ChatGPT-4Customer SupportContent CreationEducational…

4 months ago

APJ Abdul Kalam Biography: A Tribute to India’s Powerful Missile Man

APJ Abdul Kalam Biography :Childhood :Academics :Professional Career :Achievements : APJ Abdul Kalam Biography :…

7 months ago

Srinivasa Ramanujan Biography: Exploring the Genius

We value your feedback! Please share your thoughts on this blog on Srinivasa Ramanujan Biography…

7 months ago

Interim Budget 2024: What to Expect Any Rise

Interim Budget 2024 :Importance :Key Points :Rise in 80 C ?Standard Deduction : Interim Budget…

8 months ago

This website uses cookies.