CIS 111 Lists/Arrays

Objectives

  • Use lists in Python to count character occurrences in text.
  • Use selection to solve a programming problem.
  • Use repetition to solve a programming problem using accumulators.
  • Display calculation results.

Program requirements

The challenge in this assignment is to write the pseudocode and a program that asks the user for input and then displays the count of each digit contained in that input. The user should be able to enter any regular characters and continue until they type "QUIT" (either uppercase or lowercase). Check the sample output for details about how your program should operate.

You are required to use a list of ten elements to store the counts for the digits. Lists in Python are similar to using arrays in many other languages.

Sample run

This program counts digit frequencies in the input Enter a string (QUIT to exit): There were 14 students in class today. Enter another string (QUIT to exit): 101 Dalmatians Enter another string (QUIT to exit): 76 trombones in the big parade Enter another string (QUIT to exit): A stitch in time saves 9 Enter another string (QUIT to exit): 2b || !2b Enter another string (QUIT to exit): 123.45 Enter another string (QUIT to exit): 99.87 Enter another string (QUIT to exit): \/\/3 4r3 7h5 1337 h4ck3r5 Enter another string (QUIT to exit): quit The count for digit 0 is 1 The count for digit 1 is 5 The count for digit 2 is 3 The count for digit 3 is 6 The count for digit 4 is 4 The count for digit 5 is 3 The count for digit 6 is 1 The count for digit 7 is 4 The count for digit 8 is 1 The count for digit 9 is 3

Rubric

  • 10 points for correct pseudocode
  • 10 points for correct use of lists
  • 5 points for using repetition and selection to properly iterate through a string and count digits
  • 5 points for using repetition to properly get user input until QUIT is entered
  • 5 points for using repetition to properly display the output using one print statement in the code
  • 5 points for proper documentation comments and for correctly following coding conventions (indentation, naming rules, etc.)