Ai Open Ended-2
Ai Open Ended-2
ALAPPUZHA-04
SUBMITTED BY
NANDU PRASANNAN
1
CARMEL POLYTECHNIC COLLEGE
ALAPPUZHA - 04
CERTIFICATE
This is the bonafide report of the project entitled “NUMBER GUESSING GAME”
presented and submitted by NANDU PRASANNAN (Register No:2201131802) of Fifth
semester computer engineering, for the partial fulfilment of the requirements for the award
of Diploma in Computer Engineering under the Board Of Technical Education, Kerala
during the academic year 2023-2024 at Carmel Polytechnic College, Alappuzha.
2
ACKNOWLEDGEMENT
I express My sincere thanks to all of My teachers for their support and coordination they
rendered to me. I extend My sincere thanks to all who have helped and encouraged me to
conduct this seminar, above all I express My thanks to God almighty for his blessing and
helped me to overcome all difficulties on the way of My Open-ended Project
3
NUMBER GUESSING GAME
PROGRAM
import random
def ai_guess_game():
print("Welcome to the AI Number Guessing Game!")
print("Think of a number between 1 and 100.")
input("Press Enter when you're ready...")
low = 1
high = 100
guesses = 0
ai_guess = None
user_feedback = input("Is your number higher (h), lower (l), or is the guess correct (c)? ").lower()
if user_feedback == 'c':
print(f"Yay! The AI guessed your number {ai_guess} in {guesses} guesses!")
break
elif user_feedback == 'h':
low = ai_guess + 1
elif user_feedback == 'l':
high = ai_guess - 1
else:
print("Invalid input. Please respond with 'h', 'l', or 'c'.")
4
OUTPUT
Think of a number between 1 and 100. Press Enter when you're ready... YES
• AI guesses: 50
Is your number higher (h), lower (l), or is the guess correct (c)? : h
• AI guesses: 75
Is your number higher (h), lower (l), or is the guess correct (c)? : l
• AI guesses: 62
Is your number higher (h), lower (l), or is the guess correct (c)? : l
• AI guesses: 56
Is your number higher (h), lower (l), or is the guess correct (c)? : c