Practice Test 4 - AP Computer Science Principles
20 questions. Answer them in any order, then submit to see your score and every explanation.
- A user receives an email that appears to be from a popular social media site. The email warns that the user's account will be deactivated unless they click a link and enter their login credentials to confirm their identity. This is most likely an attempt at what type of attack?
- To best improve the fault tolerance of the business's Internet access, which action should be taken?
- A program filters survey responses by iterating through a list, but it fails to progress. Examine the following code snippet: `responses <- ["yes", "no", "yes"] countYes <- 0 index <- 0 WHILE (index < LENGTH(responses)) { IF (responses[index] = "yes") { countYes <- countYes + 1 } // missing update to index here } PRINT(countYes)` Identify the error in the loop structure that prevents it from functioning as intended.
- Considering the example provided, an Online Retail System wants to recommend products without reading every single click and message. The real-world problem is that raw data (every item viewed, time spent, cart edits, purchases, returns, and star ratings) is overwhelming for quick recommendations. The system abstracts customer data into three simplified structures: CustomerProfile (age range, region, preferred categories), PurchasePatterns (most-bought categories, average price range, repeat purchases), and FeedbackSummary (average rating by category, common return reasons). This classification reduces complexity by turning thousands of events into a few meaningful summaries. During development, programmers design algorithms that manipulate these abstractions, not the raw logs. For example, a recommendation algorithm scores items using the abstracted purchase pattern and feedback summary. Pseudocode: score(item) = 0 IF item.category IN PurchasePatterns.topCategories THEN score += 2 IF item.price BETWEEN PurchasePatterns.minPrice AND maxPrice THEN score += 1 IF FeedbackSummary.avgRating[item.category] >= 4 THEN score += 1 Which abstraction technique is used in the scenario to simplify data handling?
- A city government uses an algorithm to predict which neighborhoods are most likely to experience crime. The algorithm is trained on historical arrest data. This leads to increased police presence in certain neighborhoods, which in turn leads to more arrests in those areas, further reinforcing the algorithm's predictions. This situation raises a significant ethical concern primarily related to which of the following?
- A simple game simulation updates a player's score each frame until it reaches a goal. Examine the following code snippet, where a
WHILEloop iterates to update game state repeatedly.score <- 0goal <- 10WHILE score < goalscore <- score + 2 // earn points each updateEND WHILEDISPLAY(score)The loop checksscore < goalbefore every iteration, increasesscoreby 2 each time, and terminates oncescoreis no longer less thangoal. The purpose is to simulate repeated updates until a stopping condition is met. Examine the following code snippet: How many times does the loop execute? - In a computer network, what is the most accurate definition of a 'path' between two computers?
- In the following code segment, under what condition will "Grade A" be displayed? IF(score >= 90) { DISPLAY("Grade A") } IF(score >= 80) { DISPLAY("Grade B") } IF(score >= 70) { DISPLAY("Grade C") }
- In physics, Elena uses NumPy (a math library) to handle a matrix of coefficients. Libraries reduce effort by providing tested functions. With
import numpy as np, she writesA = np.array([[1,2,3],[4,5,6],[7,8,9]]). Using the library mentioned, what is the output ofA.shape? - ## Economic Barriers: Affordability and Access ### Definition and significance The digital divide is the gap between those who have dependable internet, devices, and digital skills and those who do not. It matters because job searches, school portals, and health information increasingly require online access. ### What studies suggest Pew Research Center has consistently found that adults with lower household incomes are less likely to have home broadband and a computer, and more likely to be "smartphone-only" internet users. Smartphone-only access can be limiting for tasks like writing essays, completing job applications, or uploading documents. ### How it affects different groups - Socioeconomic status: A family may delay internet service to pay for rent or utilities. - Geographic location: Fewer providers can keep prices higher in some areas. - Age: Some older adults may avoid online banking due to low confidence. ### Efforts to bridge the divide Communities often combine: - discounted broadband plans - refurbished device programs - public Wi-Fi in libraries and community centers - digital literacy workshops ### Key takeaway The text highlights affordability as a major barrier, alongside infrastructure and skills. Based on the text, what is a significant barrier to closing the digital divide as mentioned in the passage?
- A programmer uses hand tracing to debug a loop that should print numbers 1 through 10. The hand trace reveals that the loop prints numbers 1 through 9 and then stops. What does this technique help identify?
- Based on the text, safe computing in a hospital billing office includes strong access control, timely updates, and careful handling of patient data. The office keeps insurance records on a shared drive, and only certain roles should open them. Privacy concerns grow when staff store files on personal devices, because control and auditing weaken. Security concerns grow when systems skip updates, because attackers exploit known weaknesses. The hospital adds data encryption, meaning files become unreadable without an authorized key. It also uses two-factor authentication, which requires a password plus a second check, such as a code. Ethical computing requires protecting vulnerable patients and avoiding unnecessary data collection. A breach occurs when an employee uses a simple password and reuses it on a social site. Attackers guess the password, enter the billing system, and expose thousands of records. The hospital pays notification costs, faces regulatory fines, and loses community trust (Health and Human Services [HHS], 2021). What is the purpose of two-factor authentication in the passage?
- Refer to the text: genome sequencing pipelines may distribute data across nodes to handle massive read volumes. Which scenario best exemplifies distributed computing?
- A sensor readings list of integers starts as [19, 21, 20, 22, 18]. You receive a new reading and add it using readings.append(23) to keep the sequence. Based on the scenario above, how many elements are in the list after the given operations?
- A program is intended to create an acronym from a three-word phrase stored in the string variables
w1,w2, andw3. For example, ifw1is"Computer",w2is"Science", andw3is"Principles", the acronym should be"CSP". Assuming a procedure returns the first character of a string, which expression creates the correct acronym? - Binary Basics passage: Binary is base-2 and uses only 0 and 1, unlike decimal base-10. A quick example is decimal 10 written as binary 1010. Computers use these 0/1 states as bits for storage and processing, often grouping bits into bytes. According to the text, What is the binary representation of the decimal number 10?
- Which of the following statements best describes a fault-tolerant computer system?
- A city builds a Traffic Management System to reduce rush-hour delays using data abstraction. Road sensors stream raw records like (timestamp, intersectionID, laneID, speed, vehicleCount). To simplify, the system classifies each intersection into an abstract summary: totalVehiclesPerMinute, averageSpeed, and a congestionLevel label (LOW/MED/HIGH). It stores these summaries in a list of IntersectionStatus objects instead of keeping every raw sensor record for decision-making. An algorithm runs every minute to adjust signal timing: it finds intersections with HIGH congestion, then increases their green time by 5 seconds while decreasing nearby LOW intersections by 5 seconds, keeping total cycle time constant. Example pseudocode:
FOR each status IN intersectionStatuses: IF status.congestionLevel = "HIGH": status.greenTime ← status.greenTime + 5 ELSE IF status.congestionLevel = "LOW": status.greenTime ← status.greenTime - 5Based on the scenario described, how does data abstraction facilitate algorithmic processing in the described system? - A development team is using an incremental development process to build a new word processing application. Which of the following best describes their approach?
- If isMember is true and total is 99 during seasonal sale, what is the discount? // Online Shopping Cart discount rules IF isMember IF total >= 100 IF isSeasonalSale discount = 20 ELSE discount = 15 ELSE discount = 5 ELSE IF total >= 150 IF isSeasonalSale discount = 10 ELSE discount = 0 ELSE discount = 0