Spring2015.CSCI220Homework2 History

Hide minor edits - Show changes to output

Changed lines 37-38 from:
1 2 13(:sourcend:)
to:
1 2 12(:sourcend:)
Changed line 53 from:
5 55 361(:sourcend:)
to:
5 55 360(:sourcend:)
Deleted lines 10-13:
!!!Note

Make sure your program is user-friendly, i.e., that it provides a meaningful input prompt and output message.
Added lines 16-66:
!!Input and Output

The input to the program is a filename of a text file, e.g., "text.txt".

This file may contain zero or more lines, with zero or more words.

Below are some examples.

'''Note:''' The output of your program should be formatted '''precisely''' as shown below, as your program may be tested automatically.


!!!Example 1

If the input file contains this:

(:source tabwidth=3 -trim :)
Hello world!(:sourcend:)

your program's output should be this:

(:source lang=Python tabwidth=3 -trim :)
1 2 13(:sourcend:)

!!!Example 2

If the input file contains this:

(:source tabwidth=3 -trim :)
Python is a widely used general-purpose, high-level programming language.
Its design philosophy emphasizes code readability, and its syntax allows
programmers to express concepts in fewer lines of code than would be possible in
languages such as C++ or Java. The language provides constructs intended to
enable clear programs on both a small and large scale.(:sourcend:)

your program's output should be this:

(:source lang=Python tabwidth=3 -trim :)
5 55 361(:sourcend:)

!!!Example 3

If the input file is completely empty (i.e., no newlines, nothing):

(:source tabwidth=3 -trim :)
(:sourcend:)

your program's output should be this:

(:source lang=Python tabwidth=3 -trim :)
0 0 0(:sourcend:)
Changed lines 69-71 from:
If the user makes an error, output a meaningful error and terminate. If the input is correct, perform the calculations and output the result.

If
you do the bonus, make sure you update the header documentation below to reflect that.
to:
If the user makes an error, output a meaningful error and terminate. If the input is correct, perform the calculations and output the result.

If
you do the bonus, make sure you update the header documentation to reflect that.
Added lines 1-46:
'''Assigned Date''': Friday, Feb. 13, 2015\\
'''Due Date''': Friday, Feb. 20, 2015\\
'''Due Time''': 12:20pm

Last modified on {$LastModified} [-(see [[http://www.cs.cofc.edu/~manaris/index.php/Spring2015.CSCI220Homework2?action=diff&source=n&minor=n | updates]]) -]

!!Assignment

Write a program that reads in a file and calculates the number of lines, words, and characters contained. The program should accept a filename as input and then print three numbers showing the count of lines, words, and characters in the file. [-(This is the same as exercise 15, p. 121 of the textbook.)-]

!!!Note

Make sure your program is user-friendly, i.e., that it provides a meaningful input prompt and output message.

!!Learning Objectives

* To learn the fundamentals of procedural analysis and design.
* To learn the features of procedural programming: the major types of statements, such as assignment, repetition, and the major data types, such as integers, real numbers, and character strings.

!!Bonus

If the user makes an error, output a meaningful error and terminate. If the input is correct, perform the calculations and output the result.

If you do the bonus, make sure you update the header documentation below to reflect that.

!!Documentation

In general, you should comment any variable, obscure statement, block of code, etc. you create.

Additionally, your code should always have header documentation that explains what the program does, in general terms.

Follow the documentation instructions from [[Spring2015.CSCI220Homework1 | Homework 1]]. In particular, you should modify these comments, to fit the new assignment.

!!Submissions

You will submit your assignment via [[https://lms.cofc.edu/ | OAKS]]. Your submission consists of:

# Your Python program. Call it, '''wc.py'''.

# A printout of your program - to be submitted in class on the due date.

# If you do the bonus, submit a separate, additional program. Give this program a different name, i.e., '''wc.bonus.py'''

!!Grading

Your grade will be based on how well you followed the above instructions.