Answered step by step
Verified Expert Solution
Question
1 Approved Answer
A program is required to calculate the cost of a plumber's visit. If it is a non - urgent job, a plumber charges a 1
A program is required to calculate the cost of a plumber's visit. If it is a nonurgent job, a
plumber charges a call out fee that also covers the first hour minutes of work. Each
whole hour, or part of an hour, after that is charged at However, if it is an urgent job, the
call out fee that covers the first hour is and each hour or part of an hour after that is
charged at
So for example, if the plumber takes minutes to complete an urgent job, the first
minutes costs The remaining minutes cost as there are complete hours
and then part of an hour, which are each charged at making a total bill of For the
same number of minutes for a nonurgent job, the total bill is for the call out and
for the hours and part hour, so the total bill is
You are given part of the test data Table and an errorfilled program this can be
downloaded from the assessment page
Table
# Problen: Calculate plunber's bill.
# Input: ninutes worked
# Input: True if urgent, False othervise
# Output: cost
minutes
urgent False
cost
hours
if minutes :
hours nimutes
if ninutes :
hours ninutes
if urgent
cost hours
if not urgent:
cost hours
printcost
a
iDescribe the inputs of this program, including their admissible values.
iiGive an explanation for the choice of input values shown in the test table.
iii.Describe how you would extend the testing strategy to ensure that the program works for shorter jobs.
marks
b
iWhat are the syntax errors in this program? Consider no other errors at this point.
iiCorrect the syntax errors. Now test your program for a nonurgent job of minutes. Explain why the code fails.
marks
c
iExplain, in ordinary English, what the purpose of the first if statement is and how this is achieved in the Python code.
iiThis program is currently based on Pattern Explain why Pattern would be better at expressing the last two multiple cases.
iii.Using Pattern write an algorithm for this scenario. Your algorithm must initialise minutes and urgent to admissible values.
marks
dThis part of the question involves writing Python code. Produce code corresponding to your algorithm. Include comments. Use the test table to check your code works. You do not need to submit test outputs.
Name your Python file QOUCU.py where OUCU is your OU computer username, eg abc Then include the code file in your TMA zip file.
Paste your completed Python code into your solution document as text, using an evenly spaced font such as Courier New or Consolas.
marks
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started