answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
bija089 [108]
1 year ago
14

Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working. Describe each pos

sibility in your own words. Define "precondition" and "postcondition" as part of your description. Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.
Computers and Technology
1 answer:
ss7ja [257]1 year ago
4 0

Answer:

Explanation:

If a function is not working, there are three possibilities to consider: There is something wrong with the arguments the function is getting; a precondition is violated. There is something wrong with the function; a postcondition is violated. There is something wrong with the return value or the way it is being used.

a. precondition

A precondition is a prerequisite. It's the thing that has to happen before something else happens. ... When it's a verb, precondition means to prepare something (or someone).

b)a postcondition

A postcondition is the states the system can be in after the use case has ended. Consider the following: The states described by pre- or postconditions should be states that the user can observe. "The user has logged on to the system" or "The user has opened the document" are examples of observable states.

c)As in any programming language, "return value" means the value that is returned by any sub-routine. All subroutines need not return values, sometimes return void (means nothing). Return values often indicate something about the completion of the task or result of an operation.

You might be interested in
A file concordance tracks the unique words in a file and their frequencies. Write a program that displays a concordance for a fi
neonofarm [45]

Answer:

Python file with appropriate comments given below

Explanation:

#Take the input file name

filename=input('Enter the input file name: ')

#Open the input file

inputFile = open(filename,"r+")

#Define the dictionary.

list={}

#Read and split the file using for loop

for word in inputFile.read().split():

  #Check the word to be or not in file.

  if word not in list:

     list[word] = 1

  #increment by 1

  else:

     list[word] += 1

#Close the file.

inputFile.close();

#print a line

print();

#The word are sorted as per their ASCII value.

fori in sorted(list):

  #print the unique words and their

  #frequencies in alphabetical order.

  print("{0} {1} ".format(i, list[i]));

3 0
2 years ago
Row array gameScores contains all player scores. Construct a row array highScores than contains all player scores greater than m
Sever21 [200]

Answer:

The solution is written using Python as it has a simple syntax.

  1. def getHighScores(gameScores, minScore):
  2.    meetsThreshold = []
  3.    for score in gameScores:
  4.        if(score > minScore):
  5.            meetsThreshold.append(score)
  6.    return meetsThreshold
  7. gameScores = [2, 5, 7, 6, 1, 9, 1]
  8. minScore = 5
  9. highScores = getHighScores(gameScores, minScore)
  10. print(highScores)

Explanation:

Line 1-8

  • Create a function and name it as <em>getHighScores</em> which accepts two values, <em>gameScores</em> and <em>minScore</em>. (Line 1)
  • Create an empty list/array and assign it to variable <em>meetsThreshold</em>. (Line 2)
  • Create a for loop to iterate through each of the score in the <em>gameScores</em> (Line 4)
  • Set a condition if the current score is bigger than the <em>minScore</em>, add the score into the <em>meetsThreshold</em> list (Line 5-6)
  • Return <em>meetsThreshold</em> list as the output

Line 11-12

  • create a random list of <em>gameScores</em> (Line 11)
  • Set the minimum score to 5 (Line 12)

Line 13-14

  • Call the function <em>getHighScores()</em> and pass the<em> gameScores</em> and <em>minScore </em>as the arguments. The codes within the function <em>getHighScores()</em>  will run and return the <em>meetsThreshold </em>list and assign it to <em>highScores.</em> (Line 13)
  • Display <em>highScores</em> using built-in function print().
8 0
1 year ago
Problem statement: Using loop, write a program that will ask the user to enter a character for left or right. Then, the user wil
zvonat [6]
Define variables
left is l
right is r

Ask input
left or right

Ask input value

Equate l or r to the input value

Show ladder with steps equal to input value and in the side of input variable
7 0
1 year ago
Information is stored on a compact disk in a coded pattern of tiny pits arranged in a track that spirals outward toward the rim
Maksim231197 [3]

Answer:

(i) The rotation speed must stay the same.

(ii) The rotation speed must increase.

(iii) The rotation speed must decrease.

Explanation:

According to Equation

10.10, the angular speed must therefore vary as the laser–lens system moves

radially along the disc. In a typical CD player, the constant speed of the surface at

the point of the laser–lens system is 1.3 m/s.

5 0
1 year ago
The microprogram counter (MPC) contains the address of the next microcode statement for the Mic1 emulator to execute. The MPC va
Ray Of Light [21]

Answer:

MAR bit

Explanation:

The MPC computers area set of software and hardware standards that was developed by the consortium of computer firms which is led by Microsoft. It contains the address of a next microcode for the Mic1 emulator foe execution.

The part of the executing microcode instruction that determines the value which is placed in the MOC is the MAR bit. The MAR is the memory address register in the CPU which stores the memory address or such addresses to which some data will be sent and also stored.

6 0
1 year ago
Other questions:
  • Which statements describe the advantages of using XML?
    12·2 answers
  • List three functions that you can perform with a database that you cannot perform with a spreadsheet.
    11·1 answer
  • When a typeface does not have any extra embellishments on the top and bottom of the letterforms, it is called a ________ font?
    12·1 answer
  • Have you ever tried to teach a class full of restless, active sixth-graders? I have. I taught sixth-grade students for 12 years.
    15·1 answer
  • When driving, your attention is __________.
    5·2 answers
  • Fill in the blank; "As well as their traditional role of computing data, computers are also extensively used for..."
    14·1 answer
  • Prompt: Which references and reference formats are you most likely to use? Why?<br><br><br> ED2020
    13·2 answers
  • "Suppose there is a class Alarm. Alarm has two class variables, code which contains a String value representing the code that de
    10·1 answer
  • Given a sorted array of integer, A, with possible duplicate elements. Implement an efficient (sublinear running time complexity)
    12·1 answer
  • Represent the logic of a program that allows the user to enter a value for one edge of a cube. The program calculates the surfac
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!