#!/usr/bin/env python3 """ Text to Python Conversion Generated: 2026-10-05T10:26:59.818Z Total Lines: 1083 """ def process_text(): """ Process and analyze text data Returns: dictionary with text data and metadata """ text_lines = [ "\"\"\"", "File Sample - Python Sample File", "Website: https://filessample.com", "Description:", "A simple Python example demonstrating variables, functions,", "lists, dictionaries, searching, filtering, and file information.", "\"\"\"", "# ==========================================", "# Website Information", "# ==========================================", "WEBSITE_NAME = \"File Sample\"", "WEBSITE_DOMAIN = \"filessample.com\"", "WEBSITE_URL = \"https://filessample.com\"", "print(\"Welcome to\", WEBSITE_NAME)", "print(\"Website:\", WEBSITE_URL)", "# ==========================================", "# Website Description", "# ==========================================", "website_description = (", " \"File Sample provides free sample files and \"", " \"useful information about different file formats.\"", ")", "print(website_description)", "# ==========================================", "# Sample File Data", "# ==========================================", "sample_files = [", " {", " \"id\": 1,", " \"name\": \"document-sample.pdf\",", " \"type\": \"PDF\",", " \"category\": \"Documents\",", " \"size\": \"245 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 2,", " \"name\": \"document-sample.docx\",", " \"type\": \"DOCX\",", " \"category\": \"Documents\",", " \"size\": \"32 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 3,", " \"name\": \"spreadsheet-sample.xlsx\",", " \"type\": \"XLSX\",", " \"category\": \"Spreadsheet\",", " \"size\": \"18 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 4,", " \"name\": \"data-sample.json\",", " \"type\": \"JSON\",", " \"category\": \"Data\",", " \"size\": \"8 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 5,", " \"name\": \"data-sample.xml\",", " \"type\": \"XML\",", " \"category\": \"Data\",", " \"size\": \"12 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 6,", " \"name\": \"data-sample.yaml\",", " \"type\": \"YAML\",", " \"category\": \"Data\",", " \"size\": \"6 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 7,", " \"name\": \"image-sample.jpg\",", " \"type\": \"JPG\",", " \"category\": \"Images\",", " \"size\": \"156 KB\",", " \"downloadable\": True", " }", "]", "# ==========================================", "# Display All Files", "# ==========================================", "def display_files(files):", " \"\"\"Display information about all sample files.\"\"\"", " print(\"\\nAvailable Sample Files\")", " print(\"-\" * 45)", " for file in files:", " print(", " f\"{file['id']}. \"", " f\"{file['name']} - \"", " f\"{file['type']} - \"", " f\"{file['size']}\"", " )", "display_files(sample_files)", "# ==========================================", "# Search Files", "# ==========================================", "def search_files(keyword):", " \"\"\"", " Search sample files by name, type,", " or category.", " \"\"\"", " keyword = keyword.lower().strip()", " results = []", " for file in sample_files:", " if (", " keyword in file[\"name\"].lower()", " or keyword in file[\"type\"].lower()", " or keyword in file[\"category\"].lower()", " ):", " results.append(file)", " return results", "# ==========================================", "# Example Search", "# ==========================================", "search_keyword = \"json\"", "results = search_files(search_keyword)", "print(\"\\nSearch Results for:\", search_keyword)", "if results:", " for file in results:", " print(", " f\"- {file['name']} \"", " f\"({file['type']})\"", " )", "else:", " print(\"No files found.\")", "# ==========================================", "# Find File By ID", "# ==========================================", "def find_file_by_id(file_id):", " for file in sample_files:", " if file[\"id\"] == file_id:", " return file", " return None", "selected_file = find_file_by_id(3)", "print(\"\\nSelected File:\")", "if selected_file:", " print(selected_file[\"name\"])", " print(\"Type:\", selected_file[\"type\"])", " print(\"Size:\", selected_file[\"size\"])", "else:", " print(\"File not found.\")", "# ==========================================", "# Filter Files By Category", "# ==========================================", "def filter_by_category(category):", " category = category.lower()", " return [", " file", " for file in sample_files", " if file[\"category\"].lower() == category", " ]", "document_files = filter_by_category(\"Documents\")", "print(\"\\nDocument Files:\")", "for file in document_files:", " print(\"-\", file[\"name\"])", "# ==========================================", "# Check Download Availability", "# ==========================================", "def check_download(file):", " if file[\"downloadable\"]:", " return f\"{file['name']} is available for download.\"", " return f\"{file['name']} is not available.\"", "print(\"\\nDownload Status:\")", "for file in sample_files:", " print(check_download(file))", "# ==========================================", "# Website Statistics", "# ==========================================", "statistics = {", " \"total_files\": len(sample_files),", " \"free_downloads\": True,", " \"website_status\": \"Active\",", " \"categories\": [", " \"Documents\",", " \"Spreadsheet\",", " \"Data\",", " \"Images\"", " ]", "}", "print(\"\\nWebsite Statistics\")", "print(\"-\" * 30)", "print(\"Total Files:\", statistics[\"total_files\"])", "print(\"Free Downloads:\", statistics[\"free_downloads\"])", "print(\"Website Status:\", statistics[\"website_status\"])", "# ==========================================", "# File Type Counter", "# ==========================================", "def count_file_types(files):", " file_types = {}", " for file in files:", " file_type = file[\"type\"]", " if file_type in file_types:", " file_types[file_type] += 1", " else:", " file_types[file_type] = 1", " return file_types", "file_type_counts = count_file_types(sample_files)", "print(\"\\nFile Type Summary:\")", "for file_type, count in file_type_counts.items():", " print(f\"{file_type}: {count}\")", "# ==========================================", "# Website Categories", "# ==========================================", "categories = [", " {", " \"name\": \"Documents\",", " \"formats\": [", " \"PDF\",", " \"DOC\",", " \"DOCX\",", " \"TXT\",", " \"ODT\"", " ]", " },", " {", " \"name\": \"Spreadsheet\",", " \"formats\": [", " \"XLS\",", " \"XLSX\",", " \"CSV\",", " \"ODS\"", " ]", " },", " {", " \"name\": \"Data\",", " \"formats\": [", " \"JSON\",", " \"XML\",", " \"YAML\",", " \"CSV\",", " \"TSV\"", " ]", " },", " {", " \"name\": \"Images\",", " \"formats\": [", " \"JPG\",", " \"PNG\",", " \"WEBP\",", " \"GIF\",", " \"TIFF\"", " ]", " }", "]", "print(\"\\nAvailable Categories:\")", "for category in categories:", " print(", " f\"{category['name']}: \"", " + \", \".join(category[\"formats\"])", " )", "# ==========================================", "# Simple Greeting Function", "# ==========================================", "def welcome_message():", " message = (", " \"Thank you for visiting \"", " \"File Sample at filessample.com.\"", " )", " return message", "print(\"\\n\" + welcome_message())", "# ==========================================", "# Program Completed", "# ==========================================", "print(\"\\nProgram completed successfully.\")", "print(\"Visit:\", WEBSITE_URL)", "\"\"\"", "File Sample - Python Sample File", "Website: https://filessample.com", "Description:", "A simple Python example demonstrating variables, functions,", "lists, dictionaries, searching, filtering, and file information.", "\"\"\"", "# ==========================================", "# Website Information", "# ==========================================", "WEBSITE_NAME = \"File Sample\"", "WEBSITE_DOMAIN = \"filessample.com\"", "WEBSITE_URL = \"https://filessample.com\"", "print(\"Welcome to\", WEBSITE_NAME)", "print(\"Website:\", WEBSITE_URL)", "# ==========================================", "# Website Description", "# ==========================================", "website_description = (", " \"File Sample provides free sample files and \"", " \"useful information about different file formats.\"", ")", "print(website_description)", "# ==========================================", "# Sample File Data", "# ==========================================", "sample_files = [", " {", " \"id\": 1,", " \"name\": \"document-sample.pdf\",", " \"type\": \"PDF\",", " \"category\": \"Documents\",", " \"size\": \"245 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 2,", " \"name\": \"document-sample.docx\",", " \"type\": \"DOCX\",", " \"category\": \"Documents\",", " \"size\": \"32 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 3,", " \"name\": \"spreadsheet-sample.xlsx\",", " \"type\": \"XLSX\",", " \"category\": \"Spreadsheet\",", " \"size\": \"18 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 4,", " \"name\": \"data-sample.json\",", " \"type\": \"JSON\",", " \"category\": \"Data\",", " \"size\": \"8 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 5,", " \"name\": \"data-sample.xml\",", " \"type\": \"XML\",", " \"category\": \"Data\",", " \"size\": \"12 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 6,", " \"name\": \"data-sample.yaml\",", " \"type\": \"YAML\",", " \"category\": \"Data\",", " \"size\": \"6 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 7,", " \"name\": \"image-sample.jpg\",", " \"type\": \"JPG\",", " \"category\": \"Images\",", " \"size\": \"156 KB\",", " \"downloadable\": True", " }", "]", "# ==========================================", "# Display All Files", "# ==========================================", "def display_files(files):", " \"\"\"Display information about all sample files.\"\"\"", " print(\"\\nAvailable Sample Files\")", " print(\"-\" * 45)", " for file in files:", " print(", " f\"{file['id']}. \"", " f\"{file['name']} - \"", " f\"{file['type']} - \"", " f\"{file['size']}\"", " )", "display_files(sample_files)", "# ==========================================", "# Search Files", "# ==========================================", "def search_files(keyword):", " \"\"\"", " Search sample files by name, type,", " or category.", " \"\"\"", " keyword = keyword.lower().strip()", " results = []", " for file in sample_files:", " if (", " keyword in file[\"name\"].lower()", " or keyword in file[\"type\"].lower()", " or keyword in file[\"category\"].lower()", " ):", " results.append(file)", " return results", "# ==========================================", "# Example Search", "# ==========================================", "search_keyword = \"json\"", "results = search_files(search_keyword)", "print(\"\\nSearch Results for:\", search_keyword)", "if results:", " for file in results:", " print(", " f\"- {file['name']} \"", " f\"({file['type']})\"", " )", "else:", " print(\"No files found.\")", "# ==========================================", "# Find File By ID", "# ==========================================", "def find_file_by_id(file_id):", " for file in sample_files:", " if file[\"id\"] == file_id:", " return file", " return None", "selected_file = find_file_by_id(3)", "print(\"\\nSelected File:\")", "if selected_file:", " print(selected_file[\"name\"])", " print(\"Type:\", selected_file[\"type\"])", " print(\"Size:\", selected_file[\"size\"])", "else:", " print(\"File not found.\")", "# ==========================================", "# Filter Files By Category", "# ==========================================", "def filter_by_category(category):", " category = category.lower()", " return [", " file", " for file in sample_files", " if file[\"category\"].lower() == category", " ]", "document_files = filter_by_category(\"Documents\")", "print(\"\\nDocument Files:\")", "for file in document_files:", " print(\"-\", file[\"name\"])", "# ==========================================", "# Check Download Availability", "# ==========================================", "def check_download(file):", " if file[\"downloadable\"]:", " return f\"{file['name']} is available for download.\"", " return f\"{file['name']} is not available.\"", "print(\"\\nDownload Status:\")", "for file in sample_files:", " print(check_download(file))", "# ==========================================", "# Website Statistics", "# ==========================================", "statistics = {", " \"total_files\": len(sample_files),", " \"free_downloads\": True,", " \"website_status\": \"Active\",", " \"categories\": [", " \"Documents\",", " \"Spreadsheet\",", " \"Data\",", " \"Images\"", " ]", "}", "print(\"\\nWebsite Statistics\")", "print(\"-\" * 30)", "print(\"Total Files:\", statistics[\"total_files\"])", "print(\"Free Downloads:\", statistics[\"free_downloads\"])", "print(\"Website Status:\", statistics[\"website_status\"])", "# ==========================================", "# File Type Counter", "# ==========================================", "def count_file_types(files):", " file_types = {}", " for file in files:", " file_type = file[\"type\"]", " if file_type in file_types:", " file_types[file_type] += 1", " else:", " file_types[file_type] = 1", " return file_types", "file_type_counts = count_file_types(sample_files)", "print(\"\\nFile Type Summary:\")", "for file_type, count in file_type_counts.items():", " print(f\"{file_type}: {count}\")", "# ==========================================", "# Website Categories", "# ==========================================", "categories = [", " {", " \"name\": \"Documents\",", " \"formats\": [", " \"PDF\",", " \"DOC\",", " \"DOCX\",", " \"TXT\",", " \"ODT\"", " ]", " },", " {", " \"name\": \"Spreadsheet\",", " \"formats\": [", " \"XLS\",", " \"XLSX\",", " \"CSV\",", " \"ODS\"", " ]", " },", " {", " \"name\": \"Data\",", " \"formats\": [", " \"JSON\",", " \"XML\",", " \"YAML\",", " \"CSV\",", " \"TSV\"", " ]", " },", " {", " \"name\": \"Images\",", " \"formats\": [", " \"JPG\",", " \"PNG\",", " \"WEBP\",", " \"GIF\",", " \"TIFF\"", " ]", " }", "]", "print(\"\\nAvailable Categories:\")", "for category in categories:", " print(", " f\"{category['name']}: \"", " + \", \".join(category[\"formats\"])", " )", "# ==========================================", "# Simple Greeting Function", "# ==========================================", "def welcome_message():", " message = (", " \"Thank you for visiting \"", " \"File Sample at filessample.com.\"", " )", " return message", "print(\"\\n\" + welcome_message())", "# ==========================================", "# Program Completed", "# ==========================================", "print(\"\\nProgram completed successfully.\")", "print(\"Visit:\", WEBSITE_URL)\"\"\"", "File Sample - Python Sample File", "Website: https://filessample.com", "Description:", "A simple Python example demonstrating variables, functions,", "lists, dictionaries, searching, filtering, and file information.", "\"\"\"", "# ==========================================", "# Website Information", "# ==========================================", "WEBSITE_NAME = \"File Sample\"", "WEBSITE_DOMAIN = \"filessample.com\"", "WEBSITE_URL = \"https://filessample.com\"", "print(\"Welcome to\", WEBSITE_NAME)", "print(\"Website:\", WEBSITE_URL)", "# ==========================================", "# Website Description", "# ==========================================", "website_description = (", " \"File Sample provides free sample files and \"", " \"useful information about different file formats.\"", ")", "print(website_description)", "# ==========================================", "# Sample File Data", "# ==========================================", "sample_files = [", " {", " \"id\": 1,", " \"name\": \"document-sample.pdf\",", " \"type\": \"PDF\",", " \"category\": \"Documents\",", " \"size\": \"245 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 2,", " \"name\": \"document-sample.docx\",", " \"type\": \"DOCX\",", " \"category\": \"Documents\",", " \"size\": \"32 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 3,", " \"name\": \"spreadsheet-sample.xlsx\",", " \"type\": \"XLSX\",", " \"category\": \"Spreadsheet\",", " \"size\": \"18 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 4,", " \"name\": \"data-sample.json\",", " \"type\": \"JSON\",", " \"category\": \"Data\",", " \"size\": \"8 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 5,", " \"name\": \"data-sample.xml\",", " \"type\": \"XML\",", " \"category\": \"Data\",", " \"size\": \"12 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 6,", " \"name\": \"data-sample.yaml\",", " \"type\": \"YAML\",", " \"category\": \"Data\",", " \"size\": \"6 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 7,", " \"name\": \"image-sample.jpg\",", " \"type\": \"JPG\",", " \"category\": \"Images\",", " \"size\": \"156 KB\",", " \"downloadable\": True", " }", "]", "# ==========================================", "# Display All Files", "# ==========================================", "def display_files(files):", " \"\"\"Display information about all sample files.\"\"\"", " print(\"\\nAvailable Sample Files\")", " print(\"-\" * 45)", " for file in files:", " print(", " f\"{file['id']}. \"", " f\"{file['name']} - \"", " f\"{file['type']} - \"", " f\"{file['size']}\"", " )", "display_files(sample_files)", "# ==========================================", "# Search Files", "# ==========================================", "def search_files(keyword):", " \"\"\"", " Search sample files by name, type,", " or category.", " \"\"\"", " keyword = keyword.lower().strip()", " results = []", " for file in sample_files:", " if (", " keyword in file[\"name\"].lower()", " or keyword in file[\"type\"].lower()", " or keyword in file[\"category\"].lower()", " ):", " results.append(file)", " return results", "# ==========================================", "# Example Search", "# ==========================================", "search_keyword = \"json\"", "results = search_files(search_keyword)", "print(\"\\nSearch Results for:\", search_keyword)", "if results:", " for file in results:", " print(", " f\"- {file['name']} \"", " f\"({file['type']})\"", " )", "else:", " print(\"No files found.\")", "# ==========================================", "# Find File By ID", "# ==========================================", "def find_file_by_id(file_id):", " for file in sample_files:", " if file[\"id\"] == file_id:", " return file", " return None", "selected_file = find_file_by_id(3)", "print(\"\\nSelected File:\")", "if selected_file:", " print(selected_file[\"name\"])", " print(\"Type:\", selected_file[\"type\"])", " print(\"Size:\", selected_file[\"size\"])", "else:", " print(\"File not found.\")", "# ==========================================", "# Filter Files By Category", "# ==========================================", "def filter_by_category(category):", " category = category.lower()", " return [", " file", " for file in sample_files", " if file[\"category\"].lower() == category", " ]", "document_files = filter_by_category(\"Documents\")", "print(\"\\nDocument Files:\")", "for file in document_files:", " print(\"-\", file[\"name\"])", "# ==========================================", "# Check Download Availability", "# ==========================================", "def check_download(file):", " if file[\"downloadable\"]:", " return f\"{file['name']} is available for download.\"", " return f\"{file['name']} is not available.\"", "print(\"\\nDownload Status:\")", "for file in sample_files:", " print(check_download(file))", "# ==========================================", "# Website Statistics", "# ==========================================", "statistics = {", " \"total_files\": len(sample_files),", " \"free_downloads\": True,", " \"website_status\": \"Active\",", " \"categories\": [", " \"Documents\",", " \"Spreadsheet\",", " \"Data\",", " \"Images\"", " ]", "}", "print(\"\\nWebsite Statistics\")", "print(\"-\" * 30)", "print(\"Total Files:\", statistics[\"total_files\"])", "print(\"Free Downloads:\", statistics[\"free_downloads\"])", "print(\"Website Status:\", statistics[\"website_status\"])", "# ==========================================", "# File Type Counter", "# ==========================================", "def count_file_types(files):", " file_types = {}", " for file in files:", " file_type = file[\"type\"]", " if file_type in file_types:", " file_types[file_type] += 1", " else:", " file_types[file_type] = 1", " return file_types", "file_type_counts = count_file_types(sample_files)", "print(\"\\nFile Type Summary:\")", "for file_type, count in file_type_counts.items():", " print(f\"{file_type}: {count}\")", "# ==========================================", "# Website Categories", "# ==========================================", "categories = [", " {", " \"name\": \"Documents\",", " \"formats\": [", " \"PDF\",", " \"DOC\",", " \"DOCX\",", " \"TXT\",", " \"ODT\"", " ]", " },", " {", " \"name\": \"Spreadsheet\",", " \"formats\": [", " \"XLS\",", " \"XLSX\",", " \"CSV\",", " \"ODS\"", " ]", " },", " {", " \"name\": \"Data\",", " \"formats\": [", " \"JSON\",", " \"XML\",", " \"YAML\",", " \"CSV\",", " \"TSV\"", " ]", " },", " {", " \"name\": \"Images\",", " \"formats\": [", " \"JPG\",", " \"PNG\",", " \"WEBP\",", " \"GIF\",", " \"TIFF\"", " ]", " }", "]", "print(\"\\nAvailable Categories:\")", "for category in categories:", " print(", " f\"{category['name']}: \"", " + \", \".join(category[\"formats\"])", " )", "# ==========================================", "# Simple Greeting Function", "# ==========================================", "def welcome_message():", " message = (", " \"Thank you for visiting \"", " \"File Sample at filessample.com.\"", " )", " return message", "print(\"\\n\" + welcome_message())", "# ==========================================", "# Program Completed", "# ==========================================", "print(\"\\nProgram completed successfully.\")", "print(\"Visit:\", WEBSITE_URL)", "\"\"\"", "File Sample - Python Sample File", "Website: https://filessample.com", "Description:", "A simple Python example demonstrating variables, functions,", "lists, dictionaries, searching, filtering, and file information.", "\"\"\"", "# ==========================================", "# Website Information", "# ==========================================", "WEBSITE_NAME = \"File Sample\"", "WEBSITE_DOMAIN = \"filessample.com\"", "WEBSITE_URL = \"https://filessample.com\"", "print(\"Welcome to\", WEBSITE_NAME)", "print(\"Website:\", WEBSITE_URL)", "# ==========================================", "# Website Description", "# ==========================================", "website_description = (", " \"File Sample provides free sample files and \"", " \"useful information about different file formats.\"", ")", "print(website_description)", "# ==========================================", "# Sample File Data", "# ==========================================", "sample_files = [", " {", " \"id\": 1,", " \"name\": \"document-sample.pdf\",", " \"type\": \"PDF\",", " \"category\": \"Documents\",", " \"size\": \"245 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 2,", " \"name\": \"document-sample.docx\",", " \"type\": \"DOCX\",", " \"category\": \"Documents\",", " \"size\": \"32 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 3,", " \"name\": \"spreadsheet-sample.xlsx\",", " \"type\": \"XLSX\",", " \"category\": \"Spreadsheet\",", " \"size\": \"18 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 4,", " \"name\": \"data-sample.json\",", " \"type\": \"JSON\",", " \"category\": \"Data\",", " \"size\": \"8 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 5,", " \"name\": \"data-sample.xml\",", " \"type\": \"XML\",", " \"category\": \"Data\",", " \"size\": \"12 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 6,", " \"name\": \"data-sample.yaml\",", " \"type\": \"YAML\",", " \"category\": \"Data\",", " \"size\": \"6 KB\",", " \"downloadable\": True", " },", " {", " \"id\": 7,", " \"name\": \"image-sample.jpg\",", " \"type\": \"JPG\",", " \"category\": \"Images\",", " \"size\": \"156 KB\",", " \"downloadable\": True", " }", "]", "# ==========================================", "# Display All Files", "# ==========================================", "def display_files(files):", " \"\"\"Display information about all sample files.\"\"\"", " print(\"\\nAvailable Sample Files\")", " print(\"-\" * 45)", " for file in files:", " print(", " f\"{file['id']}. \"", " f\"{file['name']} - \"", " f\"{file['type']} - \"", " f\"{file['size']}\"", " )", "display_files(sample_files)", "# ==========================================", "# Search Files", "# ==========================================", "def search_files(keyword):", " \"\"\"", " Search sample files by name, type,", " or category.", " \"\"\"", " keyword = keyword.lower().strip()", " results = []", " for file in sample_files:", " if (", " keyword in file[\"name\"].lower()", " or keyword in file[\"type\"].lower()", " or keyword in file[\"category\"].lower()", " ):", " results.append(file)", " return results", "# ==========================================", "# Example Search", "# ==========================================", "search_keyword = \"json\"", "results = search_files(search_keyword)", "print(\"\\nSearch Results for:\", search_keyword)", "if results:", " for file in results:", " print(", " f\"- {file['name']} \"", " f\"({file['type']})\"", " )", "else:", " print(\"No files found.\")", "# ==========================================", "# Find File By ID", "# ==========================================", "def find_file_by_id(file_id):", " for file in sample_files:", " if file[\"id\"] == file_id:", " return file", " return None", "selected_file = find_file_by_id(3)", "print(\"\\nSelected File:\")", "if selected_file:", " print(selected_file[\"name\"])", " print(\"Type:\", selected_file[\"type\"])", " print(\"Size:\", selected_file[\"size\"])", "else:", " print(\"File not found.\")", "# ==========================================", "# Filter Files By Category", "# ==========================================", "def filter_by_category(category):", " category = category.lower()", " return [", " file", " for file in sample_files", " if file[\"category\"].lower() == category", " ]", "document_files = filter_by_category(\"Documents\")", "print(\"\\nDocument Files:\")", "for file in document_files:", " print(\"-\", file[\"name\"])", "# ==========================================", "# Check Download Availability", "# ==========================================", "def check_download(file):", " if file[\"downloadable\"]:", " return f\"{file['name']} is available for download.\"", " return f\"{file['name']} is not available.\"", "print(\"\\nDownload Status:\")", "for file in sample_files:", " print(check_download(file))", "# ==========================================", "# Website Statistics", "# ==========================================", "statistics = {", " \"total_files\": len(sample_files),", " \"free_downloads\": True,", " \"website_status\": \"Active\",", " \"categories\": [", " \"Documents\",", " \"Spreadsheet\",", " \"Data\",", " \"Images\"", " ]", "}", "print(\"\\nWebsite Statistics\")", "print(\"-\" * 30)", "print(\"Total Files:\", statistics[\"total_files\"])", "print(\"Free Downloads:\", statistics[\"free_downloads\"])", "print(\"Website Status:\", statistics[\"website_status\"])", "# ==========================================", "# File Type Counter", "# ==========================================", "def count_file_types(files):", " file_types = {}", " for file in files:", " file_type = file[\"type\"]", " if file_type in file_types:", " file_types[file_type] += 1", " else:", " file_types[file_type] = 1", " return file_types", "file_type_counts = count_file_types(sample_files)", "print(\"\\nFile Type Summary:\")", "for file_type, count in file_type_counts.items():", " print(f\"{file_type}: {count}\")", "# ==========================================", "# Website Categories", "# ==========================================", "categories = [", " {", " \"name\": \"Documents\",", " \"formats\": [", " \"PDF\",", " \"DOC\",", " \"DOCX\",", " \"TXT\",", " \"ODT\"", " ]", " },", " {", " \"name\": \"Spreadsheet\",", " \"formats\": [", " \"XLS\",", " \"XLSX\",", " \"CSV\",", " \"ODS\"", " ]", " },", " {", " \"name\": \"Data\",", " \"formats\": [", " \"JSON\",", " \"XML\",", " \"YAML\",", " \"CSV\",", " \"TSV\"", " ]", " },", " {", " \"name\": \"Images\",", " \"formats\": [", " \"JPG\",", " \"PNG\",", " \"WEBP\",", " \"GIF\",", " \"TIFF\"", " ]", " }", "]", "print(\"\\nAvailable Categories:\")", "for category in categories:", " print(", " f\"{category['name']}: \"", " + \", \".join(category[\"formats\"])", " )", "# ==========================================", "# Simple Greeting Function", "# ==========================================", "def welcome_message():", " message = (", " \"Thank you for visiting \"", " \"File Sample at filessample.com.\"", " )", " return message", "print(\"\\n\" + welcome_message())", "# ==========================================", "# Program Completed", "# ==========================================", "print(\"\\nProgram completed successfully.\")", "print(\"Visit:\", WEBSITE_URL)" ] # Calculate metadata metadata = { 'total_lines': 1083, 'total_characters': 29144, 'total_words': 2431, 'created_at': '2026-10-05T10:26:59.819Z', 'version': '1.0' } # Calculate statistics line_lengths = [len(line) for line in text_lines] statistics = { 'average_line_length': sum(line_lengths) // len(line_lengths) if line_lengths else 0, 'longest_line': max(line_lengths) if line_lengths else 0, 'shortest_line': min(line_lengths) if line_lengths else 0, 'empty_lines': 386 } return { 'lines': text_lines, 'metadata': metadata, 'statistics': statistics } def display_text(data): """Display text data with metadata""" print("Metadata:") for key, value in data['metadata'].items(): print(f" {key}: {value}") print("\nStatistics:") for key, value in data['statistics'].items(): print(f" {key}: {value}") print("\nText Lines:") for i, line in enumerate(data['lines'], 1): print(f"Line {i}: {line}") if __name__ == "__main__": data = process_text() display_text(data)