Posts

Showing posts from April, 2023

Snake, Water Or Gun Game Using Python

 Snake, Water Or Gun Game Using Python : import random def gameWin ( comp , you ):     if comp == you:         return None     elif comp == 's' :         if you == 'w' :             return False         elif you == 'g' :             return True     elif comp == 'w' :         if you == 'g' :             return False         elif you == 's' :             return True     elif comp == 'g' :         if you == 's' :             return False         elif you == 'w' :             return True print ( "Computer's Turn: Snake(s), Water(w), or Gun(g)?" ) randNo = random.randint( 1 , 3 ) if randNo == 1 :     com...

Number Guessing Game Using Python 3

Number Guessing Game Using Python 3: import random num_rounds = 5 max_guesses = 10 score = 0 print ( "Welcome to the Number Guessing Game!" ) print ( "You will play" , num_rounds, "rounds. Each round, you have to guess a number between 1 and 100." ) print ( "You will score points based on the number of attempts taken to guess the number." ) print ( "Let's get started! \n " ) for i in range (num_rounds):     secret_number = random.randint( 1 , 100 )     num_guesses = 0     print ( "Round" , i+ 1 , "starts now!" )     # print("Your Guessing Number is:",secret_number)     while num_guesses < max_guesses:         guess = int ( input ( "Guess a number between 1 and 100: " ))         num_guesses += 1         if guess == secret_number:             print ( "Congratulations! You guessed the secret number in" , num_guesses, "guesses!" )    ...