Practice validation, aggregation, file output, and defensive handling of mixed-quality input.
Write a program that:
- Repeatedly reads integer scores until the user enters
-1. - Accepts only values in the range
0..100. - Ignores invalid numeric values outside the accepted range.
- Prints:
- count of valid scores
- average score
- minimum score
- maximum score
- frequency table by tens (
0-9,10-19, ...,90-100)
- Writes the same report to
core_assessment_report.txt.
- Difficulty: Intermediate.
- Estimated Time: 45-60 minutes.
- Prerequisites: All
02-coremodules, especiallyinput-validation,maps-and-frequency-counting, anderror-handling-and-defensive-programming. - Learning Focus: Prove validation, aggregation, defensive handling, and report generation under mixed-quality input.
python main.py91
88
72
105
60
-1
Valid scores: 4
Average: 77.75
Minimum: 60
Maximum: 91
Frequency:
- 0-9: 0
- 10-19: 0
- 20-29: 0
- 30-39: 0
- 40-49: 0
- 50-59: 0
- 60-69: 1
- 70-79: 1
- 80-89: 1
- 90-100: 1
Report written to core_assessment_report.txt
- Compared with the C++ assessment, this version shortens the mechanics of filtering and counting while keeping the same correctness bar.
- Relative to C#, Go, and TypeScript, more trust is placed in disciplined runtime checks than in compile-time structure.
- The comparison to watch is concise code versus explicit static guarantees.
- out-of-range or malformed values do not pollute the valid-score summary
- frequency buckets match the accepted scores exactly
- the generated report contains the same summary shape promised by the README