Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Write a client/server application using Python to implement a program in which server takes a string as input and then returns the number of characters,

Write a client/server application using Python to implement a program in which server takes a string as input and then returns the number of characters, words and lines in the input string to client.

a) The client inputs from user (a string) and sends it to the server through TCP socket connection

b) The server takes a string as input and then returns the number of characters, words and lines in the input string to client.

Input: This is the "first line" of the string

this is the 'second'

and this is the third

Output: Number of characters = 82

Number of words = 17

Number of lines = 3

Declare a variable that keeps track of whether you are currently reading a word (as oppose to reading a space or newline character) or not. Initialize the variable to reflect that you are currently not reading a word

Item Iterate through the string one character at a time.

Increment the number of characters seen

if the character is a newline character:

increment the number of lines if the character is a newline or a space:

change your state variable to reflect the fact that you are not reading a word

else if you are outside a word:

increment the number of words and change your state reflect that you are inside a word

d) The client then displays the result to the user. And asks users if he wants to perform another count. If Yes, repeat all steps else just terminate.

e) You must provide a command-line interactive interface.

f) Code should be well documented.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

More Books

Students also viewed these Databases questions