Bonjourno everyone!
this is my first coding project in fusion, and I’ve made a number guessing game with the help of google Gemini!
Here is the link to the project if you do want to try it out yourself
Here is the link to the transcript between me and Google Gemini
Here is the line by line code explanation
import random
This line imports Python’s built-in random module, which allows the program to generate random numbers. We need it to pick a secret number for the guessing game.
secret_number = random.randint(1, 100)
Here, we use random.randint(1, 100) to generate a random integer between 1 and 100 (inclusive). This number is stored in secret_number and is what the player needs to guess.
guess = 0
print(” I’m thinking of a number between 1 and 100.”)
print(“Can you guess what it is?”)
These lines display a message to the player, explaining the game and prompting them to guess a number.
while guess != secret_number:
while True:
player_input = input(“Enter your guess: “)
try:
guess = int(player_input)
break
except ValueError:
print(“That’s not a valid number. Please enter an integer.”)
while guess != secret_number:
This while loop keeps the game running as long as the player’s guess is not equal to the secret number. Once the guess matches the secret number, the loop stops.
player_input = input(“Enter your guess: “)
guess = int(player_input)
The program asks the player to enter a guess. Since input() returns a string, we convert it to an integer using int() so we can compare it to the secret number numerically.
if guess < secret_number: print(“Too low! Try again.”) elif guess > secret_number:
print(“Too high! Try again.”)
These lines check the player’s guess:
If it’s smaller than the secret number, the program says “Too low!”
If it’s larger, it says “Too high!”
This feedback helps the player adjust their next guess.
print(f”🎉 You got it! The secret number was{secret_number}.”)
Once the loop ends (meaning the player guessed correctly), the program congratulates the player and reveals the secret number. The f before the string lets us insert the value of secret_number directly into the message.
and here is the thoght process I took while coding this, in a flowchart

Thanks for reading!
Leave a Reply