Back to homeAP® Computer Science Principles · AP Computer Science Principles · Change subject
Start for free
Notes

Exercises: The development process

Practice★☆☆
These phases of program development are out of order: (a) testing the program with different data, (b) editing the source code, (c) debugging found errors, (d) running…

These phases of program development are out of order: (a) testing the program with different data, (b) editing the source code, (c) debugging found errors, (d) running the program. Put them in a logical order and explain what is done in each phase, taking into account that testing may require going back a step.

Solve
Practice★☆☆
Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the…

Explain what a bug in a program is and what debugging means. Give a simple example of an error that an ATM program could have and what consequence it would have for the user.

Solve
Practice★☆☆
The figure shows the software development workflow cycle, but one of its stages is covered with a question mark, as shown in the figure. State which stage is missing…

The figure shows the software development workflow cycle, but one of its stages is covered with a question mark, as shown in the figure.

Edit code Run and test does it work properly? ? Publish program no yes

State which stage is missing from the cycle, what it consists of, and why the "no" arrow sends the work back to editing the code.

Solve
Practice★☆☆
Explain what a trace or log message is in a program and how it helps to find an error (it allows you to see which path the program took and with what values).

Explain what a trace or log message is in a program and how it helps to find an error (it allows you to see which path the program took and with what values).

Solve
Practice★☆☆
Programs have versions (1.0, 1.1, 2.0, etc.). Explain the purpose of keeping versions of code and what you can do if the latest version performs worse than the previous…

Programs have versions (1.0, 1.1, 2.0, etc.). Explain the purpose of keeping versions of code and what you can do if the latest version performs worse than the previous one.

Solve
Practice★☆☆
Explain what a test case is and write two test cases for a program that adds two numbers: one with normal values and one with a special value, stating the input and…

Explain what a test case is and write two test cases for a program that adds two numbers: one with normal values and one with a special value, stating the input and expected result for each.

Solve
Practice★☆☆
Documentation accompanies a program. Explain at least two things it should cover (what the program does and how to use it) and why undocumented software degrades poorly…

Documentation accompanies a program. Explain at least two things it should cover (what the program does and how to use it) and why undocumented software degrades poorly over time when a team works on it.

Solve
Practice★☆☆
Distinguish between a compile-time error (the program does not even start) and a runtime error (it starts but fails with certain data), giving an example of each type.

Distinguish between a compile-time error (the program does not even start) and a runtime error (it starts but fails with certain data), giving an example of each type.

Solve
Practice★★☆
Explain the difference between a syntax error and a logic error, giving an example of each in a program that calculates the mean of three scores. Which of the two types…

Explain the difference between a syntax error and a logic error, giving an example of each in a program that calculates the mean of three scores. Which of the two types prevents the program from running, and which allows it to run but produces incorrect results?

Solve
Practice★★☆
A program that divides two numbers works fine in almost all tests, but fails when the divisor is 0. Explain what boundary values or edge cases are in testing, why they…

A program that divides two numbers works fine in almost all tests, but fails when the divisor is 0. Explain what boundary values or edge cases are in testing, why they must always be tested, and state two other values with which you would test this program.

Solve
Practice★★☆
Explain what modularization of a program is (dividing it into functions or modules) and analyze two advantages it offers when development is carried out by a team of…

Explain what modularization of a program is (dividing it into functions or modules) and analyze two advantages it offers when development is carried out by a team of several people: think about division of work, testing, and error localization.

Solve
Practice★★☆
A loop in a program never stops. Explain where you would place temporary print statements to diagnose it (inside the loop, displaying the control variable in each…

A loop in a program never stops. Explain where you would place temporary print statements to diagnose it (inside the loop, displaying the control variable in each iteration) and what you would look for in those statements to find the cause.

Solve
Practice★★☆
To test a program that applies a discount to people aged 65 or over, define three test cases: one with a normal value, one with the exact boundary value, and one with an…

To test a program that applies a discount to people aged 65 or over, define three test cases: one with a normal value, one with the exact boundary value, and one with an invalid value (negative or impossible age), with the expected result for each. Justify your choices.

Solve
Practice★★☆
Explain what refactoring is (improving code without changing its external behavior) and describe two typical refactorings (renaming variables with clear names,…

Explain what refactoring is (improving code without changing its external behavior) and describe two typical refactorings (renaming variables with clear names, extracting a function from repeated code), with an example of each.

Solve
Practice★★☆
A code snippet uses the variables x, y2, and zzz to store the price, sales tax, and total. Rewrite these names meaningfully and explain why choosing descriptive names…

A code snippet uses the variables x, y2, and zzz to store the price, sales tax, and total. Rewrite these names meaningfully and explain why choosing descriptive names helps prevent errors (making the code self-documenting).

Solve
Practice★★☆
Two members of a team edit the same project file at the same time and, when merging changes, a conflict arises. Explain what a merge conflict is, how it is resolved…

Two members of a team edit the same project file at the same time and, when merging changes, a conflict arises. Explain what a merge conflict is, how it is resolved (reviewing both versions and deciding), and which two team habits prevent it (dividing work by modules, integrating changes frequently).

Solve
Practice★★★
In the billing system of a school co-op, it has been detected that when issuing the monthly invoice, the total amount payable for some members is incorrect. You have the…

In the billing system of a school co-op, it has been detected that when issuing the monthly invoice, the total amount payable for some members is incorrect. You have the following system logs available:

  • Member 101: 2 purchases of 15.00 dollars -> Total billed: 30.00 dollars (expected: 30.00 dollars).

  • Member 102: 1 purchase of 50.00 dollars with a 10 % promotional discount (5.00 dollars) and a 3.00 dollars management fee surcharge -> Total billed: 47.50 dollars (expected: 48.00 dollars).

  • Member 103: 1 purchase of 20.00 dollars and 1 item return of 5.00 dollars (-5.00 dollars) -> Total billed: 25.00 dollars (expected: 15.00 dollars).

  • Formulate a justified hypothesis about the logic or order-of-operations bug that explains the error for Member 102 and Member 103.

  • Design the debugging strategy to confirm your hypotheses: indicate what minimum test data you would input to isolate the bug, at what points in the execution flow you would place breakpoints, and what specific variables you should inspect step by step.

Solve
Practice★★★
Design a test plan for a program that asks for two numbers and displays their quotient: create a data table with at least six test cases (pairs of input values,…

Design a test plan for a program that asks for two numbers and displays their quotient: create a data table with at least six test cases (pairs of input values, including normal, boundary, and invalid values), the expected result for each, and what the program should do if the input is invalid. Justify the choice of each case.

Solve
Practice★★★
The school's intranet implements an authentication module with the following requirements: Username: 4 to 12 alphanumeric characters, case-insensitive. Password: between…

The school's intranet implements an authentication module with the following requirements:

  • Username: 4 to 12 alphanumeric characters, case-insensitive.

  • Password: between 8 and 16 characters, case-sensitive, with at least one digit and one special character.

  • Security: temporary account lockout for 15 minutes after three consecutive failed attempts.

Design a rigorous test plan using a table with at least six test cases designed by you. For each case, you must specify: identifier, input values (username and password), previous system state, expected result, and what specific logic, boundary, or security risk you are validating.

Solve
Practice★★★
A group of three students is going to develop an attendance tracking app for the school over ten weeks. To avoid delays and last-minute failed deliveries, you must…

A group of three students is going to develop an attendance tracking app for the school over ten weeks. To avoid delays and last-minute failed deliveries, you must structure the team's working methodology:

  1. Design a schedule organized into four verifiable milestones or deliverables, explaining what objective criteria must be met before authorizing the transition to the next milestone.

  2. Define a formal peer review protocol (code review): establish who reviews whose code, what minimum quality checklist must be passed before accepting any changes, and how disagreements are managed.

  3. Establish and justify a "code freeze" policy: in which week it must be activated, what type of modifications are strictly prohibited from that moment on, and what exclusive tasks the team must undertake until the final delivery.

Solve
Practice★★★
Topic Challenge. As a junior software analyst, you are going to design a Python script (you can use a free web environment like Replit) that evaluates daily energy costs…

Topic Challenge. As a junior software analyst, you are going to design a Python script (you can use a free web environment like Replit) that evaluates daily energy costs to promote household savings.

Follow these three phases:

  1. Data gathering: Go to the website of your local electric utility or the U.S. Energy Information Administration (EIA) and record the official price ($\$/\text{kWh}$) for $6$ different time slots today.

  2. Design and coding: Apply the software development process. First, sketch the algorithm and translate it into Python. The program must store the data in a list, use an iterative loop to calculate the average daily cost, and use conditionals (if-else) that issue alerts when the price exceeds the threshold of $0.18$ dollars/kWh.

  3. Debugging and final product: Test with edge cases and fix runtime errors. Write a brief report that includes the clean, commented code, a screenshot of the console output, and two efficient consumption proposals for your home based on your data.

Assessment criteria:

  • Rigor in the development process (prior algorithmic design, textual coding, and debugging).

  • Correct use of control structures (sequential, conditional, and iterative) and language syntax.

  • Accuracy in processing real data and feasibility of the energy conclusions.

Solve