Brand Logo
Sign in
Search any post

Here you got every thing related with technology and coding

Here you got every thing related with technology and coding
1/2
0
0
0
Report
https://www.postlo.com/p/f9Bod4O0iC/india-bihar-patna-t-here-you-got-every-thing-related-with
Please Sign-in first for reporting post.

Here you got every thing related with technology and coding

Description

Here you got every thing related with technology and coding in which python is best

import random

def guess_the_number():
   print("Welcome to Guess the Number!")
   secret_number = random.randint(1, 20)
   
   for attempts in range(1, 6):
       guess = int(input("Take a guess (between 1 and 20): "))
       
       if guess < secret_number:
           print("Too low! Try again.")
       elif guess > secret_number:
           print("Too high! Try again.")
       else:
           print(f"Congratulations! You guessed the number in {attempts} attempts.")
           break
   
   else:
       print(f"Sorry, the number was {secret_number}. Better luck next time!")

if __name__ == "__main__":
   guess_the_number()

City:Patna
Last Published Date:December 31, 2023
Post status: Active
Related Searches:

Suggested Posts