Count Failed, Passed and Honors Exam Results From Percentage Scores

Read the full interview experience this question came from →

Quick Overview

A coding task that classifies a list of exam scores, given as percentages, into failed, passed without honors and passed with honors bands, and returns the three counts in a fixed order. It tests careful handling of the inclusive and exclusive boundaries at 50 and 80 percent.

Count Failed, Passed and Honors Exam Results From Percentage Scores

Company: Google

Role: Software Engineer

Category: Coding & Algorithms

Difficulty: easy

Interview Round: Online Assessment

Students take an exam, and each result is a percentage score. Classify every result into one of three bands and count how many results fall into each band. ### Function Signature ```python def count_result_bands(results: list[int]) -> list[int]: ``` ### Rules - A result below 50 is **Failed**: `score < 50`. - A result from 50 to 80, both inclusive, is **Passed without Honors**: `50 <= score <= 80`. - A result above 80 is **Passed with Honors**: `score > 80`. - Return a list of exactly three integers in this order: `[failed, passed_without_honors, passed_with_honors]`. - Every result is counted in exactly one band, so the three counts sum to `len(results)`. ### Constraints - `1 <= len(results) <= 100` - Each `results[K]` is an integer with `0 <= results[K] <= 100`. The report states the band limits as percentages without giving the score range; this version fixes it to whole percentages from 0 to 100. ### Examples **Example 1** ```text Input: results = [50, 80, 81, 99, 30, 77, 67] Output: [1, 4, 2] ``` 30 is the only failed result. 50 and 80 sit exactly on the band limits and, together with 77 and 67, pass without honors. 81 and 99 pass with honors. **Example 2** ```text Input: results = [30, 30, 49] Output: [3, 0, 0] ``` **Example 3** ```text Input: results = [0, 100] Output: [1, 0, 1] ```

Overview: A coding task that classifies a list of exam scores, given as percentages, into failed, passed without honors and passed with honors bands, and returns the three counts in a fixed order. It tests careful handling of the inclusive and exclusive boundaries at 50 and 80 percent.

Read the full Google Software Engineer interview experience this question came from

Google logo
Google
Oct 26, 2026
easySoftware EngineerOnline AssessmentCoding & Algorithms
0
0

Students take an exam, and each result is a percentage score. Classify every result into one of three bands and count how many results fall into each band.

Function Signature

def count_result_bands(results: list[int]) -> list[int]:

Rules

  • A result below 50 is Failed : score < 50 .
  • A result from 50 to 80, both inclusive, is Passed without Honors : 50 <= score <= 80 .
  • A result above 80 is Passed with Honors : score > 80 .
  • Return a list of exactly three integers in this order: [failed, passed_without_honors, passed_with_honors] .
  • Every result is counted in exactly one band, so the three counts sum to len(results) .

Constraints

  • 1 <= len(results) <= 100
  • Each results[K] is an integer with 0 <= results[K] <= 100 . The report states the band limits as percentages without giving the score range; this version fixes it to whole percentages from 0 to 100.

Examples

Example 1

Input:  results = [50, 80, 81, 99, 30, 77, 67]
Output: [1, 4, 2]

30 is the only failed result. 50 and 80 sit exactly on the band limits and, together with 77 and 67, pass without honors. 81 and 99 pass with honors.

Example 2

Input:  results = [30, 30, 49]
Output: [3, 0, 0]

Example 3

Input:  results = [0, 100]
Output: [1, 0, 1]