联系方式

  • QQ:99515681
  • 邮箱:99515681@qq.com
  • 工作时间:8:00-21:00
  • 微信:codinghelp

您当前位置:首页 >> Python编程Python编程

日期:2020-11-25 10:45

COMP101 2020-21 Assignment-05: Page 1

COMP101

Introduction to Programming 2020-21

Assignment-05

Issue Date: Monday 23

rd November 2020

Submission Date: Monday 30

th November 2020 17:00

1. Overview

a) Summary:

This assignment is worth 16% of the total marks for COMP101.

You must submit an attempt at this assignment else a fail grade for the module

will be awarded. Plagiarism and collusion guidelines apply throughout.

b) Guidance:

Assessment is based on solving the problem specification in terms of design,

clarity, accuracy and appropriate use of code and documentation.

See below for assignment advice:

? No test table is needed

c) Submission (one file to be submitted):

a) Submit one .py file with filename in format of:

familyName_givenName-CA05.py e.g. Smith_John-CA05.py

Within the code, the first lines should be comment lines as follows:

#familyName_givenName University id filename Month and Year of coding, filename.py

#Brief description of the problem solved

#Smith_John 20141234 November 2021 CA-05.py

#Description here (keep it clear but brief)

c) Submit your document electronically via the department submission server:

https://sam.csc.liv.ac.uk/COMP/Submissions.pl

Earlier submission is possible, but any submission after the deadline attracts the

standard lateness penalties, see:

http://www.csc.liv.ac.uk/department/regulations/practical.html

COMP101 2020-21 Assignment-05: Page 2

2. Assessment Information

Assignment Number 05 (of 07)

Weighting 16%

Assignment Circulated See front page

Deadline See front page

Submission Mode e-submission

Learning outcome assessed 1, 4, 5, 6, 7

Purpose of assessment Fully modularise and parameterise using

sequence, selection and iteration

constructs to control I/O of strings and

numbers in successful calculations for a

given problem.

Marking criteria Total marks over seven questions as a

percentage

Submission necessary in order Yes

to satisfy module requirements? Assignments are not marked

anonymously

Late Submission Penalty Standard UoL Policy.

COMP101 2020-21 Assignment-05: Page 3

3. Problem Specification:

Implement and execute a program that ‘predicts’ user input in

the form of a game. Using guided prompts, the program

should perform input and calculation of integers and strings

and output a ‘prediction’.

Algorithm – not to be amended:

Step-1: Input single integer 1-9

Step-2: Multiply by 9

Step-3: Add the result together

Step-4: Subtract 5

Step-5: Input a country beginning with the 4th letter of the

English alphabet

Step-6: Input a mammal beginning with the 2nd letter of the

country

Step-7: Prompt to see the answer (y/n): If ‘y’, show the

‘prediction’ together with analysis

COMP101 2020-21 Assignment-05: Page 4

For illustration only – o/p of your own design :

Step-1:

Enter an integer, 1 to 9 inclusive: 5

Your first number is: 5

Step2:

What does 3 x 3 = 9

Your second number is: 45

Step-3:

Your second number is being added together

Your third number is 9

Step-4:

What does 8 - 3 = 5

Your fourth number is 5

Step-5:

['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z']

If a = 1 and z = 26, what is d = 4

Confirming the fourth letter of alphabet is: d

Enter the name of a country beginning with this letter: denmark

COMP101 2020-21 Assignment-05: Page 5

Step-6:

Your country is: denmark

Think of a mammal beginning with second letter of selected country: elephant

Step-7:

Want to see the answer? (Y/N): y

Based on the numbers: 5 45 9 5

We predict your country is Denmark and your animal is Elephant

You played the game using: 5, 45, 9, 5, denmark, elephant

COMP101 2020-21 Assignment-05: Page 6

Input and validation:

Validation is needed for each of the integer inputs in

function-1, function-2 and function-4, as the game is reliant

on correct integers being input.

If invalid data is input, this should be disallowed. Inform the

user and ask them to re-input the value until it is correct.

No validation is needed on the input string for country and

mammal in function-5 and function-6.

There is no requirement for a menu.

In main(), start the program with a simple ‘Play the game?’

type of prompt. If user replies yes, run the game, else end the

program gracefully (don’t just let it stop abruptly).

Allow the user to play as many times as they like.

COMP101 2020-21 Assignment-05: Page 7

Process:

The program should be fully modularised using functions,

arguments and parameters.

In main(), make a sequence of calls to each function, passing

arguments as needed in the order you expect the functions to

execute.

Each function should achieve one task and do it well.

There should be a minimum of seven separate functions with

no functions nested in others. Calls are via function main().

Function-1:

Prompt for input 1 to 9 inclusive

Accept an integer – validate the input

Pass the result to function-2

Function-2:

Accept the result from function-1

Prompt the user with an equation or other prompt that

produces result = 9

e.g.

what is 3 x 3 = ?

Validate the input – it must be 9

Multiply the result from function-1 by 9

Pass the result to function-3

COMP101 2020-21 Assignment-05: Page 8

Function-3:

Accept the result from function-2

Add the result together – no user input is needed here, hence

no validation:

e.g.

if the result from function-2 = 34

then result for function-3 = 3 + 4 = 7

Inform the user what the result is

Pass the result to function-4

NOTES for function-3:

To indicate appropriate testing and analysis and to aid

maintenance, use commentary in this function to explain how

you solved any code problems you encountered for this

function to operate correctly.

Keep the explanation clear and simple: Identify the

problem(s) and briefly describe your solution

Function-4:

Accept the result from function-3

Prompt the user with an equation or other prompt that

produces result = 5

e.g.

what is 8 – 3 = ?

Validate the input – it must be 5

Pass the result to function-5

Function-5:

Accept the result from function-4

COMP101 2020-21 Assignment-05: Page 9

Output a list of the English alphabet - all 26 characters (lower

case is okay) to give your user a reference point

e.g.

alphabet_list = [“a”, “b”, “c”, . . . , “x”, “y”, “z”]

Prompt the user with an equation or other prompt that

produces result = 4

e.g.

what is 2 + 2 = ?

Validate the input – it must be 4

Using the list index, confirm to the user what the fourth letter

of the alphabet is (it is ‘d’)

Prompt the user to enter a country beginning with this letter

(case does not matter and do not validate)

Pass the country to function-6

Function-6:

Accept the country from function-5

Prompt the user to input a mammal beginning with the second

letter of the country (case does not matter and do not validate)

Function-7:

In main(), when all input/processing is done, ask the user if

they want to see the answer.

If reply is yes, call a final function to show the prediction.

If reply is no, exit the program gracefully – don’t just let it

stop without informing the user what is happening.

We could argue that function-5 is ‘multi-tasking’. It accepts integer input, looks up an

item in a list, outputs the item and then prompts for string input.

But the code logically belongs together: integer 4 is linked to the list – we have to have

the integer to extract letter ‘d’ – it is always ‘d’ that we want. Being able to echo back to

the user the number 4 and letter ‘d’ helps us steer the user to input what we want them to

input - ‘denmark’ without distracting them.

COMP101 2020-21 Assignment-05: Page 10

Output (minimum):

Show your user something like the following (design is at

your discretion):

This computer can read your mind!

Based on the numbers you used:

Your country was Denmark

Your mammal was Elephant

You used these numbers:

(Show the numbers that were ‘used’ to predict the answer, i.e.

the results from function-1, 2, 3 and 4)

Your full inputs were:

(Echo all the numbers and also the strings used in the

program)

It doesn’t matter if your user has input a different country/mammal.

The game works on the probability that Denmark and Elephant are the most

likely outcomes. There will be a minority of users that think of something

different. There is no requirement to address this scenario


版权所有:编程辅导网 2021 All Rights Reserved 联系方式:QQ:99515681 微信:codinghelp 电子信箱:99515681@qq.com
免责声明:本站部分内容从网络整理而来,只供参考!如有版权问题可联系本站删除。 站长地图

python代写
微信客服:codinghelp