-
Joined
Apr 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import json | |
| def csv_to_json(csv_file, json_file): | |
| """Convert CSV file to JSON format""" | |
| data = [] | |
| with open(csv_file, mode='r') as file: | |
| csv_reader = csv.DictReader(file) | |
| for row in csv_reader: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| def fibonacci_generator(n): | |
| """A generator to yield Fibonacci sequence up to n elements.""" | |
| a, b = 0, 1 | |
| for _ in range(n): | |
| yield a | |
| a, b = b, a + b | |
| if __name__ == "__main__": | |
| n = int(input("Enter the number of Fibonacci numbers you want: ")) | |
| print("Fibonacci sequence:") |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import csv | |
| import json | |
| def convert_csv_to_json(csv_file_path, json_file_path): | |
| """Converts a CSV file to a JSON file.""" | |
| data = [] | |
| # Read the CSV file | |
| with open(csv_file_path, mode='r', encoding='utf-8') as csv_file: | |
| csv_reader = csv.DictReader(csv_file) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import os | |
| def read_file(file_path): | |
| """Reads content from a text file.""" | |
| if not os.path.exists(file_path): | |
| raise FileNotFoundError(f"File not found: {file_path}") | |
| with open(file_path, 'r') as file: | |
| return file.read() | |
| def process_content(content): |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| import random | |
| import string | |
| def generate_password(length=12, use_special_chars=True): | |
| """Generates a random password with the specified length and options.""" | |
| if length < 4: | |
| raise ValueError("Password length must be at least 4 characters.") | |
| # Define character pools | |
| letters = string.ascii_letters |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # test |