AP CSP WRITTEN RESPNSES Flashcards
Identify an expected user of your program. Describe one way your program’s design meets the needs of the user.
An expected user of my program would most likely be a person who is looking to play a fun number guessing game. The user would most likely enjoy working with numbers and guessing games based on luck.
Describe one piece of documentation that would be appropriate to include with or in your program.
Describe the intended purpose of this documentation by identifying who would use it and what they would do with it.
Comments are one piece of documentation that would be appropriate to include in my program.
Comments allow a programmer to add information in the source code that other programmers/developers
could see. One person that would benefit from the comments would be a developer who is using my
program. I could provide comments to identify what each function accomplishes within my program. This
would allow the person to know what my function does without having to trace the code to figure it out.
Explain how you used or could have used feedback, testing, or reflection in the development of your program.
I could have used feedback in program in a couple of ways in the development of my program. First, I
could use feedback from a user to see if they understand how to use the program. I could see if my
instructions are clear and they understand what values they should input. The second way is that I could
use a user’s feedback to see if the output makes sense to them. This will allow me to see if I need to refine
my output to help the user better understand certain functionalities and parts of my program.
Describe the problem that your program was created to address or the creative expression it pursues.
It allows users to provide the user entertainment with a simple guessing game.
Explain how you used or could have used testing in the development of your program.
- I could of have used testing in a couple of ways in the development of my program. One way I could
have used testing is to check for any misunderstanding that a user might have with the instructions or
values they should input. Another way I could have used testing is to check the program for various input
to make sure that it doesn’t crash and to confirm if the outputs match the inputs.
Explain how you used or could have used reflection in the development of your program.
- I could have used reflection in the development of my program to help identify any changes that could be
made. I can use the results from feedback and testing to see if there are aspects of my program that can
lead to confusion, misuse, or incorrect outputs. I can also reflect on the changes I have made by reviewing
my program documentation to see if a change I made could have caused an issue or lead to a misunderstanding of how to use the program
Consider the first iteration statement included in the Procedure section of your Personalized Project Reference. Identify the number of times the body of your iteration statement will execute. Describe a condition or error that would cause your iteration statement to not terminate and cause an infinite loop. If no such condition or error exists, explain how the loop could be modified to cause an infinite loop.
The body of the iteration statement will execute 3 or 4 times, this will depend on the random integer chosen. In order to create an infinite loop, the return statement will have to be taken out, as a return within a function causes it to stop, and return to the main code. Therefore, it will continue to run if you replace it with print listing1 rather than returning listing1.
Consider the first conditional statement in the Procedure section of your Personalized Project Reference. Write an equivalent Boolean expression for this conditional statement.
if (not=”hard”) and if (not=”medium”)
Consider the code segment in part (ii) of the List section of your Personalized Project Reference that shows how your list is being used. Explain in detailed steps how this code segment works. Your explanation must be detailed enough for someone else to write the code segment.
the code calls to the option of which the user uses
Consider the procedure included in part (i) of the Procedure section of your Personalized Project Reference. Describe a change to your procedure that will result in a run-time error. Explain why this change will result in a run-time error.
x1 = 0
y1 = r.randint(3,4)
while (int(x1) < int(y1)):
changing x1=5 will cause a runtime error because if x1=1 it will be greater than y1 automatically
Consider the procedure identified in part (i) of the Procedure section of your Personalized Project Reference. Write a call to your procedure with specific argument(s) that you could use for testing this procedure. Describe the program functionality that is related to this call.
The specific call would be remove(“1”). The remove function will remove values from the list based on
the comparison to a value. The comparison options are equal, less than, or greater than. The argument
value of “1” represents removing values using the equal to comparison. This call will allow me to test this
specific functionality.
Consider the procedure identified in part (i) of the Procedure section of your Personalized Project Reference. Identify a strategy, other than using test cases, that you can use to test the correctness of your procedure. Describe how you would use this strategy.
One strategy that I could have used to test my code other than using test cases is code tracing. I could
create a list and let num equal “1”, then “2”, then “3”. I could trace through the code using these values to
see if the lines of code analyze the correctness of the users input lists. I could also ask a fellow coder to complete the process too, then we could compare our
results
Consider the procedure identified in part (i) of the Procedure section of your Personalized Project Reference. Passing different values as arguments to a procedure can cause different segments of code to execute. Based on one of your arguments, describe where you could insert output statements in your procedure to test whether a block of code is executed or not.My procedure remove has one parameter called diff. If the argument is equal to “easy” then the first
conditional statement would be true and the code in the statement should execute. I could insert a print
statement with the message “next step guess” below the statement if(option == “easy”): so I can confirm if the
argument option is equal to “easy” the code will execute.
My procedure remove has one parameter called diff. If the argument is equal to “easy” then the first
conditional statement would be true and the code in the statement should execute. I could insert a print
statement with the message “next step guess” below the statement if(option == “easy”): so I can confirm if the
argument option is equal to “easy” the code will execute.
Suppose you are provided with a procedure called isEqual (value1, value2). The procedure returns True if the two parameters value1 and value2 are equal in value and returns false otherwise. Using the list you identified in the List section of your Personalized Project Reference, explain in detailed steps an algorithm that uses isEqual to count the number of times a certain value appears in your list. Your explanation must be detailed enough for someone else to write the program code.
- Create a for loop that runs through the list
- Use an if statement with isEqual as the condition comparing the two values
- Create a variable outside the for and set it to 0
- Have the variable increase by 1 inside the if
Consider the list identified in the List section of your Personalized Project Reference. Explain how you would need to adjust this part of your program if the list was not included in your code.
Because the list is user inputted I would need to create another random list using ra.list