Skip to content
Back to skills

Python Text File Analysis Script

ASecurity

Generates a Python 3 script using `def` functions to analyze a text file. It reads a file from the command line, identifies the most common non-whitespace letter, calculates the percentage of the word 'the' (handling punctuation), and writes the first ten words to 'Exercise_8_output.txt'.

  • 611 stars
  • 0 votes
  • 0 copies
  • 0 views
  • Added November 11, 2026
educationpythonapi

Works with

  • api

Security analysis

A100/100

Scanned November 11, 2026

npx -y skills add ECNU-ICALK/AutoSkill --skill python_text_file_analysis_script --agent claude-code

Installs into .claude/skills of the current project.

Are you the author of Python Text File Analysis Script?

Add the live security badge to your README. It updates with every re-scan.

Security grade badge for Python Text File Analysis Script
[![Security: A — Skills Directory](https://www.skillsdirectory.com/api/skills/ecnu-icalk-python-text-file-analysis-script/badge)](https://www.skillsdirectory.com/skills/ecnu-icalk-python-text-file-analysis-script)

More formats (shields.io, HTML) on the badges page. Keep it an A: scan every change in CI with Pro.

Download with Pro
SKILL.md
---
id: "24fad290-ca11-49f9-a0f0-dae67805b05a"
name: "python_text_file_analysis_script"
description: "Generates a Python 3 script using `def` functions to analyze a text file. It reads a file from the command line, identifies the most common non-whitespace letter, calculates the percentage of the word 'the' (handling punctuation), and writes the first ten words to 'Exercise_8_output.txt'."
version: "0.1.1"
tags:
  - "python"
  - "text-analysis"
  - "scripting"
  - "file-processing"
  - "coding-exercise"
triggers:
  - "create a python script to analyze text file"
  - "determines the most common letter in the file"
  - "calculates the percentage of the word the"
  - "writes the first ten words to Exercise_8_output.txt"
  - "text analysis exercise 8 python"
---

# python_text_file_analysis_script

Generates a Python 3 script using `def` functions to analyze a text file. It reads a file from the command line, identifies the most common non-whitespace letter, calculates the percentage of the word 'the' (handling punctuation), and writes the first ten words to 'Exercise_8_output.txt'.

## Prompt

# Role & Objective
You are a Python expert programmer. Create a Python 3 program using `def` functions that reads a filename from the command line and performs specific text analysis tasks.

# Operational Rules & Constraints
1. **Input Handling**: Read the filename from the command line arguments (sys.argv[1]).
2. **Most Common Letter**: Determine the most common letter in the file that is not a whitespace character. Use `collections.Counter` for efficiency. Print the result using the format: "[Letter] is the most common letter. It occurs [Count] times." Replace [Letter] with the appropriate letter in uppercase and [Count] with the number.
3. **Word 'the' Percentage**: Determine what percentage of the number of words in the file is the word "the".
   - Ignore capitalization (treat "The" and "the" as the same word).
   - Handle punctuation appropriately to ensure accurate word counting (e.g., strip punctuation from words).
   - Print the result using the format: "The is [Count] of [Total] words or [Percent]%." The percentage must have exactly two decimal places.
4. **First Ten Words**: Write the first ten words of the file (as determined by whitespace splitting) to a new file named "Exercise_8_output.txt". Assume the file is written to the same directory as the script.

# Anti-Patterns
- Do not count whitespace characters as letters.
- Do not treat "The" and "the" as different words.
- Do not round the percentage to an integer; ensure it has exactly two decimal places.
- Do not fail to handle punctuation attached to words (e.g., "the," should be counted as "the").

## Triggers

- create a python script to analyze text file
- determines the most common letter in the file
- calculates the percentage of the word the
- writes the first ten words to Exercise_8_output.txt
- text analysis exercise 8 python

Attribution

Is this your skill, or is something wrong with this listing? Request removal or report an issue. Author removals are honored within 72 hours.

View all in education →

Comments

Loading comments…

Newsletter

Get the weekly list of safe new skills, and the ones we pulled.