Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

A student wants to write a program to check whether a book ISBN number is valid or not. Here is a top - level decomposition:

A student wants to write a program to check whether a book ISBN number is valid or not. Here is a top-level decomposition:
> Check ISBN number
>> Initialise a list to the 13 digits of the ISBN number to be checked
>> Make a new list by leaving the items at the even indexes (0,2,4 etc.) unchanged and multiplying the items at the odd indexes by 3
>> Find the sum of the items in the transformed list
>> If the remainder of the sum divided by 10 is 0, result is valid, else the result is invalid
>> Print the result
So, for example, if an ISBN number is 978-0-141-18321-3 the input is this list:
[9,7,8,0,1,4,1,1,8,3,2,1,3]
and the output will be valid.
One of the tests of your code should be for an input list representing a possible ISBN number partly based on the example given above and partly derived from your PI number. So, the first six digits in your ISBN list should be the first six digits from your PI number and the remaining digits will be 1,1,8,3,2,1,3. So, for example, for the PI number B9081720, your ISBN list will be:
[9,0,8,1,7,2,1,1,8,3,2,1,3]
The first part of this question will only consider the following part of the decomposition.
>Check ISBN number
>> Initialise a list to the 13 digits of the ISBN number to be checked
>> Make a new list by leaving the items at the even indexes (including 0) unchanged and multiplying the items at the odd indexes by 3
You may want to temporarily add a print statement to check the output.
a.
o i.Describe the input data and the output data for this first task.
o ii.Specify one further input list you might use in testing in addition to the list you have created using your PI number. Make sure that you state the test input, the expected output and a brief explanation of why you selected this test.
o iii.Write an algorithm based on Pattern 2.4.
o iv.Implement your algorithm as Python code. Your code must match the steps of your algorithm and you should use comments in the code to make it clear how the two correspond. Marks will be lost if the program does not follow the algorithm. Copy your Python code, as text, into your Solution document. Name your Python file Q2a_OUCU.py, where OUCU is your OU computer username, e.g. abc123. Then include the code file in your TMA zip file.
You should aim to use only the Python features that are introduced in the module. If you decide to use techniques or language features that TM112 does not cover, you must give a justification for your decisions; otherwise, marks will be lost.

Step by Step Solution

There are 3 Steps involved in it

Step: 1

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

More Books

Students also viewed these Databases questions