Question
A)
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 a
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)
2,3,6,19
1,4,7,20
2,5,18,52
0,1,2,3
A)
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 workin
(1 point)
6
5
11
13
A)
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)
x
grade
temp
sum
A)
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 s
to find the problem?
ar[i]
ar
x
I
A)
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")
if avg >= 80 and avg < 90:
print("Your Grade is B")
if avg >= 70 and avg < 80:
print("Your Grade is C")
if avg >= 60 and avg < 70:
print("Your Grade is D")
if avg >= 0 and avg < 70:
print("Your Grade is F")
if avg < 0 or avg > 100:
print("Invalid Input!")
When you test the program for the value 65, you get the following output:
Enter numeric grade:
65
Your Grade is D
Your Grade is F
** Process exited - Return Code: 0 **
Press Enter to exit terminal
How can you locate the error?
(1 point)
Use a different editor, and see if that fixes the problem.
Use other data points, and see if they work.
Use a trace tool to go line by line and see how the program is progressing.
Use print statements, so you can locate the error.
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 a
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)
2,3,6,19
1,4,7,20
2,5,18,52
0,1,2,3
A)
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 workin
(1 point)
6
5
11
13
A)
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)
x
grade
temp
sum
A)
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 s
to find the problem?
ar[i]
ar
x
I
A)
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")
if avg >= 80 and avg < 90:
print("Your Grade is B")
if avg >= 70 and avg < 80:
print("Your Grade is C")
if avg >= 60 and avg < 70:
print("Your Grade is D")
if avg >= 0 and avg < 70:
print("Your Grade is F")
if avg < 0 or avg > 100:
print("Invalid Input!")
When you test the program for the value 65, you get the following output:
Enter numeric grade:
65
Your Grade is D
Your Grade is F
** Process exited - Return Code: 0 **
Press Enter to exit terminal
How can you locate the error?
(1 point)
Use a different editor, and see if that fixes the problem.
Use other data points, and see if they work.
Use a trace tool to go line by line and see how the program is progressing.
Use print statements, so you can locate the error.
Answers
Answered by
GPT-4o mini
Here are the answers to your questions based on the information provided:
**Question 1: Appropriate test data for age category 2 and below**
- Options: 2,3,6,19 | 1,4,7,20 | 2,5,18,52 | **0,1,2,3**
- **Correct Answer:** 0,1,2,3 (This option includes valid test cases for the "2 and below" category.)
---
**Question 2: Minimum number of data points to test the grade conversion program**
- Options: 6 | 5 | 11 | 13
- **Correct Answer:** 5 (You need at least one data point for each grade category.)
---
**Question 3: Variable to print out to debug the average grade calculation**
- Options: x | grade | temp | **sum**
- **Correct Answer:** sum (The error in the code is that `sum` is incorrectly updated; it should be `sum += temp` instead of `sum = temp + 1`.)
---
**Question 4: Variable to include in debugging the search program**
- Options: ar[i] | ar | x | **I**
- **Correct Answer:** ar[i] (You need to check the value of `ar[i]` at each iteration to understand why the comparisons are not working correctly.)
---
**Question 5: Locating the error in the grading program**
- Options: Use a different editor | Use other data points | Use a trace tool | **Use print statements**
- **Correct Answer:** Use print statements, so you can locate the error. (This will help you see the logic flow and understand why both "D" and "F" are printed.)
If you have any more questions or need further clarification, feel free to ask!
**Question 1: Appropriate test data for age category 2 and below**
- Options: 2,3,6,19 | 1,4,7,20 | 2,5,18,52 | **0,1,2,3**
- **Correct Answer:** 0,1,2,3 (This option includes valid test cases for the "2 and below" category.)
---
**Question 2: Minimum number of data points to test the grade conversion program**
- Options: 6 | 5 | 11 | 13
- **Correct Answer:** 5 (You need at least one data point for each grade category.)
---
**Question 3: Variable to print out to debug the average grade calculation**
- Options: x | grade | temp | **sum**
- **Correct Answer:** sum (The error in the code is that `sum` is incorrectly updated; it should be `sum += temp` instead of `sum = temp + 1`.)
---
**Question 4: Variable to include in debugging the search program**
- Options: ar[i] | ar | x | **I**
- **Correct Answer:** ar[i] (You need to check the value of `ar[i]` at each iteration to understand why the comparisons are not working correctly.)
---
**Question 5: Locating the error in the grading program**
- Options: Use a different editor | Use other data points | Use a trace tool | **Use print statements**
- **Correct Answer:** Use print statements, so you can locate the error. (This will help you see the logic flow and understand why both "D" and "F" are printed.)
If you have any more questions or need further clarification, feel free to ask!
There are no human answers yet. A form for humans to post answers is coming very soon!