0% found this document useful (0 votes)
8 views5 pages

Ai Open Ended-2

Al

Uploaded by

v3014r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
8 views5 pages

Ai Open Ended-2

Al

Uploaded by

v3014r
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

CARMEL POLYTECHNIC COLLEGE

ALAPPUZHA-04

DEPARTMENT OF COMPUTER ENGINEERING


(2023-2024)

FIFTH SEMESTER COMPUTER ENGINEERING

OPEN ENDED PROJECT

NUMBER GUESSING GAME

SUBMITTED BY

NANDU PRASANNAN

(REGISTER NUMBER: 2201131802)

1
CARMEL POLYTECHNIC COLLEGE
ALAPPUZHA - 04

DEPARTMENT OF COMPUTER ENGINEERING

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.

LECTURER IN CHARGE HEAD OF DEPARTMENT

INTERNAL EXAMINER EXTERNAL EXAMINER

2
ACKNOWLEDGEMENT

I hereby gladly present this seminar report on NUMBER GUESSING GAME


as the partial fulfilment of the award of Diploma in Computer Engineering
under the Board of Technical Education.

At the submission of this, I use this opportunity to say thanks to


P R E E T H I P R A K A S H , Lecturer of dept of computer engineering, Rev. Fr.
Jacob Kurian CMI, coordinator of self- financing department, Mr. JAMES DEVASIA,
Principal of Carmel Polytechnic College for providing a healthy environment as well as
their facilities.

I express My sincere thanks and gratitude to my seminar co-ordinator Mrs. DEEPA


NAIR, HOD, Lecturers of Computer Engineering Department, Carmel Polytechnic
College,
for their valuable suggestions and guidance, which enabled me to do this project well.

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

while low <= high:


guesses += 1
# AI makes a guess at the midpoint of the current range
ai_guess = (low + high) // 2
print(f"AI guesses: {ai_guess}")

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'.")

if low > high:


print("Something went wrong. Did you provide the correct feedback?")

# Run the game


ai_guess_game()

4
OUTPUT

Welcome to the AI Number Guessing Game!

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

Yay! The AI guessed your number 56 in 4 guesses!

You might also like