Computer Science I for majors by James Tam

Return to the course web page

CPSC 231: Mini-Assignment #3

Due Friday October 10, at 4 PM

New Concepts to be applied for the assignment

Description

Write a Python program that will prompt the user for a valid phone number. The value should only consist of the seven digit phone number (no area code, no spaces, no dashes). You can assume that the user will only enter numeric values. The program should repeatedly ask for a phone number until a value within the valid range has been entered. The first digit of the phone number cannot begin with a zero but may consist of another other number from 1 - 9 e.g., 0123456 IS NOT a valid phone number. The other six digits can consist of values from 0 - 9 e.g. 1, 9999999 IS a valid phone number, e.g.2, 1000000 IS a valid phone number. Once the user does enter a valid phone number then the program should not prompt again but instead should display a brief confirmation message that the value entered was okay e.g., "Thank you valid phone number entered."

Submitting your work:

  1. Assignments (source code/'dot-py' file) must be electronically submitted according to [the assignment submission requirements] using [D2L]
  2. As a reminder, you are not allowed to work in groups for this class. Copying the work of another student will be regarded as academic misconduct (cheating).  For additional details about what is and is not okay for this class please refer to the following [link].

Using pre-written Python libraries:

Aside from input()/print() and functions to convert types: str(), float(), int(), unless you are told otherwise, you will need to write your own code and cannot use other pre-written Python functions/methods.

Marking key

Feature

Marks

Prompts for phone number

1

Repeats prompt if number outside the valid range (4 marks for checking where it's too low, 4 marks for checking where it's too high)

8

Displays a confirmation message if a valid phone number is entered

2

TOTAL

11

Determining your assignment mark: Mapping of Raw score to grade point

Raw score 11 10 9 8 7 6 5 4 3 2 1 0
Grade point 4 3.7 3.3 3.0 2.7 2.3 2.0 1.7 1.3 1.0 0.7 0

Using pre-written Python libraries:

In case you are 'bored' with level of difficulty of this practice exercise and want to something a little more challenging here is a practice exercise that you can work on for extra practice (but it isn't graded): [Harder practice problem]