Home CPSC 110

Word Analysis

 

Due: October 9

 

Objective

To gain experience writing programs with loops, if statements, and strings.


 

Task

One simple way of estimating the reading difficulty of a piece of text is to calculate the average word length. Estimating reading difficulty is used by elementary educators to determine how difficult a story may be for children of different ages to read. Stories with shorter average word length will generally be easier to read.

For example the text:

Spot is a dog. Spot likes to run. See spot run.

Has an average word length of 3.09.

On the other hand, the text:

In interpolating problems, spline interpolation is often referred to as polynomial interpolation.

Has an average word length of 7.0

You will write a program that will take in some words from the user and print out the average word length. Along with the word length, you should print out a difficulty rating of "easy", "medium" or "hard".

If a piece of text has an average word length of less than 4, it should be classified as "easy". If the average word length is greater than or equal to 4, but less than 6, it should be classified as "medium". And if the average word length is greater than or equal to 6, it should be considered "hard".


 

Details


 

Example Run

Here is a couple example runs of the average word length program:

How many words will you enter? 11
Next word: Spot
Next word: is
Next word: a
Next word: dog
Next word: Spot
Next word: likes
Next word: to 
Next word: run
Next word: See
Next word: spot
Next word: run
Average Length = 3.09
Easy
How many words will you enter? 5
Next word: calculations
Next word: ergonomic
Next word: complicated
Next word: gibberish
Next word: zoological
Average Length = 10.2
Hard
How many words will you enter? 2
Next word: in
Next word: between
Average Length = 4.5
Medium

 

General Requirements

When writing your program, also be sure to:


 

Submitting

When you are finished, please submit the .py file for the assignment on Canvas.

Copyright © 2024 Ian Finlayson | Licensed under a Attribution-NonCommercial 4.0 International License.