Suppose you are creating a program that will check a person’s age to determine how much a ticket for an amusement park should cost. The age brackets are as given below.

2 and below free
3-5 $5.00
6-18 $10.00
19 and up $12.00
What would be appropriate test data to check whether the program is working properly for 2 and below category?

(1 point)
Responses

2,5,18,52
2,5,18,52

1,4,7,20
1,4,7,20

2,3,6,19
2,3,6,19

0,1,2,3
0,1,2,3

7 answers

To check whether the program is working properly for the "2 and below" category, the appropriate test data should include ages that fall within and just outside of that category.

Among the options provided, the best choice is:

0, 1, 2, 3

This set includes:

  • 0 and 1, which are both "2 and below" and should be free
  • 2, which is at the upper limit of "2 and below" and should also be free
  • 3, which is just above the "2 and below" category and should not be free (it should cost $5.00).

Thus, this choice effectively tests the boundaries of the "2 and below" category.

Suppose you are writing a program to convert numeric grades to letter grades:

print("Enter numeric grade: ")
avg = int(input())
if avg >= 90 and avg <= 100:
print("Your Grade is A")
elif avg >= 80 and avg < 90:
print("Your Grade is B")
elif avg >= 70 and avg < 80:
print("Your Grade is C")
elif avg >= 60 and avg < 70:
print("Your Grade is D")
elif avg >= 0 and avg < 60:
print("Your Grade is F")
else:
print("Invalid Input!")
You want to test that program is working properly. What is the minimum number of data points that you will need to test to make sure that program is working properly?

(1 point)
Responses

5
5

11
11

6
6

13

To ensure that the program for converting numeric grades to letter grades is working properly, you need to test the boundaries of each grade range, as well as an invalid input case. Here's the breakdown:

  1. A (90-100): Test with 90 and 100
  2. B (80-89): Test with 80 and 89
  3. C (70-79): Test with 70 and 79
  4. D (60-69): Test with 60 and 69
  5. F (0-59): Test with 0 and 59
  6. Invalid Input: Test with a value that is out of the valid range (e.g., -1 or 101)

This covers all letter grades and checks the boundaries for transitions between grades, plus an invalid input.

Therefore, the minimum number of data points needed is:

11

This would include:

  • Two points for each grade category (90, 100, 80, 89, 70, 79, 60, 69, 0, 59)
  • Plus at least one invalid input (e.g., -1 or 101).

So, the correct answer is 11.

The following program is supposed to find the average of five grades.

1 sum = 0
2 for x in range(0,5):
3 temp = float(input("Grade: "))
4 sum = temp + 1
5
6 grade = sum / 5
7 print("Grade = " + str(grade))
But the average is not printing out correctly. A sample run looks as given below.

Grade:

100

Grade:

67

Grade:

89

Grade:

92

Grade:

81

Grade = 16.4



** Process exited - Return Code: 0 **

Press Enter to exit terminal

To find the error which variable would be most appropriate to print out to debug the program?
(1 point)
Responses

grade
grade

sum
sum

temp
temp

x

To identify the error in the program’s logic for calculating the average of the grades, it's essential to focus on how the sum is being calculated in each iteration of the loop.

In the provided code, the variable sum is being incorrectly updated:

sum = temp + 1

This line adds 1 to the grade entered by the user (temp), rather than adding the grade to the existing sum. As a result, the program is not computing the total of all five grades correctly, leading to an incorrect average.

To debug the program effectively, it would be most appropriate to print the sum variable after each iteration of the loop to check how it changes throughout the process. Doing this would allow you to see whether the grades are being summed properly.

So, the most appropriate variable to print out for debugging is:

sum

Suppose you have written a simple search program as follows:

def findIt(ar, x):
for i in range (len(ar)):
if (x != int(ar[i])):
return i
return -1
v = [24, 20, 29, 32, 34, 29, 49, 46, 39, 23, 42, 24, 38]
a = int(input("search for: "))
print (findIt(v, a))
For every number except 24, the output is 0. For 24 (which should have an output of 0) the output is 1. Which variable should be included in a debugging statement before the return to find the problem?

(1 point)
Responses

ar[i]
ar[i]

i
i

x
x

ar

To debug the provided search program and understand why it's producing incorrect outputs, we should consider the logic in the if statement:

if (x != int(ar[i])):
    return i

The current logic states that if the current element in the array (ar[i]) does not equal x, the function returns the index i. This means that as soon as it finds an element that does not match x, it will exit the loop and return that index, which is not the intended behavior of a search function.

Given that the output is consistently returning 0 for every number except 24, it indicates that on the first iteration of the loop, the condition is always satisfied, causing the function to return immediately.

To identify exactly what is happening, we should print the comparison being made between x and ar[i] in the loop before the return statement. Therefore, the most useful variable to include in a debugging statement would be:

ar[i]

This will help us see the value of the current element being compared when it checks the condition against x. So, adding a statement like:

print(f"Comparing: {x} with {ar[i]}")

before the return line in the loop will provide insight into why the function is returning the index prematurely.