Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

In this assignment, you will design a simple word count Pythonprogram. A word count program is useful in word editor application.The program that receives a

In this assignment, you will design a simple word count Pythonprogram. A word count program is useful in word editor application.The program that receives a series of words from the user and keepcounting the number of words entered. The program allows the userto type ?-1? to indicate that s/he is finished providing inputs.After the user presses ?-1? key, the program prints the total wordcount. You are required to use while loop and conditionalstatements for this assignment.

image

Topics: Input, Print, Variables, Conditional Structure, While Loop Problem Statement: Word Count The purpose of this assignment is to gain experience in python's conditional structure and while loop. Lab Scenario: In this assignment, you will design a simple word count program. A word count program is useful in word editor application. The program that receives a series of words from the user and keep counting the number of words entered. The program allows the user to type "-1" to indicate that s/he is finished providing inputs. After the user presses "-1" key, the program prints the total word count. You are required to use while loop and conditional statements for this assignment. Lab Procedure: 1. Prior starting of the work consider how to design the while loop: a. What would be the loop condition? b. What would be the stopping criteria? c. How to initialize the loop variable? 2. Determine how to calculate the word count. What is the variable to store the count and where to initialize the variable? Hint: define a variable named 'total_word', initialize it before while loop and keep incrementing the variable 'total_word'. Think about the right operator which keeps adding to a variable. 3. Test the application by hand-calculating several values and use the same values to validate the operation. Sample input/output: Enter alword or type '-1' to end the program: this Enter a word or type '-1' to end the program: is Enter a word or type '-1' to end the program: a Enter a word or type '-1' to end the program: test Enter a word or type '-1' to end the program: program Enter a word or type '-1' to end the program: -1 Word count: 5

Step by Step Solution

There are 3 Steps involved in it

Step: 1

Python version 36 Python program to create a simple word count applica... 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

Starting Out With Java From Control Structures Through Data Structures

Authors: Tony Gaddis

6th Edition

0133957055, 978-0133957051

More Books

Students also viewed these Electrical Engineering questions

Question

What is the purpose of testing a program with sample data or input?

Answered: 1 week ago

Question

What is the difference between an input file and an output file?

Answered: 1 week ago