Download as docx, pdf, or txt
Download as docx, pdf, or txt
You are on page 1of 11

GOVERNMENT POLYTECHNIC AMBAD

DEPARTMENT OF COMPUTER ENGINEERING


(“PWP”)

A MICRO-PROJECT REPORT ON

“Number Guessing Game In Python”


FOR THE AWARD OF
DIPLOMA IN COMPUTER ENGINEERING

( Third Year, SEM-VI)

(2023-24)
UNDER THE GUIDANCE OF
MR.V.M.KHARMATE

SUBMITTED BY

YOGESH SANJAY PAWAR[325]


SACHIN DNYANESHWAR RATHOD [329]
AMARNATH PURUSHOTTAM SATPUTE[332]
CERTIFICATE
GOVERNMENT POLYTECHNIC AMBAD
DEPARTMENT OF COMPUTER ENGINEERING

(“PWP”)

This is to certify that the Micro-project entitled, “Number Guessing


Game In Python” which is being submitted by Roll no[325,329,332]
for the award of the diploma In Engineering & Technology, Under the
Faculty of Computer Engineering, Government Polytechnic,
Ambad, is a record of bonafied project work carried out by him under
my supervision, guidance and the same has not been submitted
elsewhere for any other degree or diploma of this or any other Board or
examining body.

Place : Ambad. ( Micro-project guide)


Date:. Mr.V.M.Kharmate
DECLARATION
We, the undesired, hereby declare that the project entitled “Number
Guessing Game In Python " is written and submitted by us to Government
Polytechnic ambad during Year 2023-24, sixth Semester for partial
fulfillment of the ‘Micro Project’ requirement of "PWP" subject under
Maharashtra State Board of Technical Education, Mumbai curriculum,
under the guidance of Mr.V.M.Kharmate is our original work. The
empirical findings in this project are based on the data collected in this
project is not copied from any other sources.

Roll NO. Enrollment No. Name Signature


325 2111620107 Pawar Yogesh Sanjay

329 2111620112 Rathod Sachin Dnyaneshwar

332 2111620117 Satpute Amarnath Purushottam


ACKNOWLEDGEMENT

I have great pleasure to express my immense gratitude towards a


dynamic person and my project guidance, Mr.V.M.Kharmate, Department of
Computer Engineering, Government Polytechnic, Ambad for giving me an
opportunity to work on an interesting topic over one semester. The work presented
here could not have been accomplished without his most competent and inspiring
guidance, incessant encouragement, constructive criticism and constant motivation
during all phases of our group Micro-project work. I am greatly indebted to him.
I am very much thankful to Mr.V.M.Kharmate Sir , Head, Department
of Computer Engineering, all HODs of various departments and Dr. A.M.
Agarkar, Principal, of Government Polytechnic, Ambad, for his encouragement
and providing me a motivating environment and project facilities in the Institute to
carry out experiments and complete this Micro-project work. I would like to
extend our thanks to all our Lecturers, staff members and all our friends who
extended their co-operation to complete the project.
I am indeed indebted to my parents and other family members for their
immense help at all levels with moral, social & financial support, care and support
throughout my studies without which my work would not have seen light of the
day.

Yours Sincerely,
1. Pawar Yogesh Sanjay
2.Rathod Sachin Dnyaneshwar.
3.Satpute Amarnath Purushottam.

INDEX
1. Introduction.

2. Code

I. MultiThreadedServer .java
II. MultiThreadedClient1.java
III. MultiThreadedClient2.java

3. Output

4. Conclusion

5. Reference

INTRODUCTION
Multi-Client Chat Server using Sockets and Threads in Java
In this project, we will learn to create a Client-Server console application in Java. The project
will help us to understand the low-level network communication, and also a low-level
understanding of how popular chat applications like messenger and WhatsApp are built.

Sockets Programming helps us to communicate with the various computers running on a


network. In Java, Socket programming can be either connection-oriented or connectionless. We
will design the connection-oriented application that uses the Client-Server model.

In the Client-Server model, the Server has a unique IP Address and port number. The client
tries to make a connection with the server using this port number and IP address. The server
listens and accepts the connection. Once the connection is built, the Server can receive a
message from the client as well as respond back a message to the client.

Since the project involves multiple clients that can send messages to each other, we will use
threads. The thread ensures that every client gets their own server socket.

For the Server application, we use the ServerSocket Class that binds to a specific port number.
We then create a server socket and listen for a connection with the Client and accept it. The
thread MultiThreadedServer is instantiated and started.
For the Client, we use the Socket class and initiate the connection to a server bypassing the IP
address and port number. We use the Scanner to get the input from the user and send the data to
the server.
We have used MultiThreadedClient1 class and MultiThreadedClient2 class to listen to the
response from the server, without getting blocked while reading from a Scanner. We have used
input BufferReader to get information from the client.
CODE
import random

# define range and max_attempts


lower_bound = 1
upper_bound = 1000
max_attempts = 10

# generate the secret number


secret_number = random.randint(lower_bound, upper_bound)

# Get the user's guess


def get_guess():
while True:
try:
guess = int(input(f"Guess a number between {lower_bound} and
{upper_bound}: "))
if lower_bound <= guess <= upper_bound:
return guess
else:
print("Invalid input. Please enter a number within the specified range.")
except ValueError:
print("Invalid input. Please enter a valid number.")

# Validate guess
def check_guess(guess, secret_number):
if guess == secret_number:
return "Correct"
elif guess < secret_number:
return "Too low"
else:
return "Too high"

# track the number of attempts, detect if the game is over


def play_game():
attempts = 0
won = False

while attempts < max_attempts:


attempts += 1
guess = get_guess()
result = check_guess(guess, secret_number)

if result == "Correct":
print(f"Congratulations! You guessed the secret number {secret_number}
in {attempts} attempts.")
won = True
break
else:
print(f"{result}. Try again!")

if not won:
print(f"Sorry, you ran out of attempts! The secret number is
{secret_number}.")

if __name__ == "__main__":
print("Welcome to the Number Guessing Game!")
play_game()

output:
 Advance Java 4th Unit
 https://youtu.be/kqBmsLvWU14?si=MjvV0xCX_OApTrF1
 https://gyawaliamit.medium.com/multi-client-chat-server-using-sockets-and-
threads-in-java-2d0b64cad4a7

CONCLUSION
Java Socket Programming provides a simple yet powerful way to enable communication
between multiple devices over a network. The use of multi-threading ensures that our chat
application can handle multiple clients simultaneously without freezing. Socket programming
has revolutionized the development of chat applications by providing an efficient, real-time
communication mechanism. This paper has provided an introduction to developing chat
applications using Socket programming, covering the underlying concepts, architecture, benefits,
practical implementation, future directions and challenge.

You might also like