source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
python_sharegpt_23k
21,192
Write a Python function to convert commonly used technological terms into their proper noun forms. The function should handle terms that are either single words or hyphenated phrases. The function should also be able to handle a predefined list of technological terms. The code should start with: ```python from typing i...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def convert_tech_terms_to_proper_nouns(tech_terms: List[str]) -> Dict[str, str]: """ Converts a list of commonly used technological terms into their proper noun forms. Args: tech_terms...
python_sharegpt_23k
21,194
Write a Python function to generate a random word from a list of English words that have the same meaning as the German word "Verantwortung" and use it in a sentence. The function should return the sentence as a string. Additionally, provide a table comparing the nuances and shades of meaning among the different words....
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_sentence(words: List[str]) -> str: """ Generates a sentence using a random word from the provided list of English words that have the same meaning as the German word "Verantwor...
python_sharegpt_23k
21,201
Write a Python function to calculate the sum of the squares of all the odd numbers between 1 and a given positive integer `n`, inclusive. The function should output a table with three columns: the first column should contain the odd numbers, the second column should contain their squares, and the third column should co...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_squares_of_odds(n: int) -> None: """ Calculate the sum of the squares of all the odd numbers between 1 and n, inclusive, and output a table with three columns: the odd numbers, their squares, and the running sum o...
python_sharegpt_23k
21,212
Write a Python function to count the number of groups in a 2D array where each group consists of adjacent elements of the same color. The function should have a time complexity of O(n), where n is the total number of elements in the matrix. The code should start with: ```python from typing import List def count_color_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def count_color_groups(matrix: List[List[int]]) -> int: """ Count the number of groups in a 2D array where each group consists of adjacent elements of the same color. Args: matrix (List[List...
python_sharegpt_23k
21,216
Write a Python function to evaluate the performance and accuracy of the `sigmoid` function under various conditions and input distributions. The function should generate random inputs within specified ranges, apply the `sigmoid` function to these inputs, and then analyze the outputs to ensure they fall within the expec...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import random import numpy as np import time def sigmoid(x: float) -> float: """ Compute the sigmoid function for a given input. Args: x (float): The input value. Returns: ...
python_sharegpt_23k
21,225
Write a Python function to calculate the sum of the first `n` natural numbers using a while loop. The function should return the result rounded to two decimal points. The code should start with: ```python def sum_of_first_n_numbers(n: int) -> float: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_first_n_numbers(n: int) -> float: """ Calculate the sum of the first n natural numbers using a while loop and return the result rounded to two decimal points. Args: n (int): The number of natural numbers ...
python_sharegpt_23k
21,226
Write a Python function to calculate the percentage of completed goals from a given list of goals. Each goal in the list is represented by a boolean value where `True` indicates a completed goal and `False` indicates an incomplete goal. The function should handle cases where the list is empty by returning 0. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def completed_goals_percentage(goals: List[bool]) -> float: """ Calculate the percentage of completed goals from a list of boolean values. Args: goals (List[bool]): A list of boolean values ...
python_sharegpt_23k
21,258
Write a Python function to perform integer division and calculate the remainder of the division. The function should take two integers as input and return a tuple containing the quotient (result of integer division) and the remainder. Additionally, the function should print a message displaying the quotient and the rem...
Here is the Python code to solve the given problem in the markdown block: ```python def integer_division_with_remainder(num1: int, num2: int) -> tuple: """ Perform integer division and calculate the remainder of the division. Args: num1 (int): The dividend. num2 (int): The divisor. Ret...
python_sharegpt_23k
21,262
Write a Python function to compute the average of numbers in a given list that are greater than 4 and less than 8. The function should handle any list of integers and return the average of the numbers that meet the specified criteria. If no numbers meet the criteria, the function should return 0. The code should start...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def average_of_numbers_between_4_and_8(data: List[int]) -> float: """ Computes the average of numbers in the given list that are greater than 4 and less than 8. Args: data (List[int]): The l...
python_sharegpt_23k
21,268
Write a Python function to generate a random sequence of 10 characters according to the following rules: 1. The first character is always an uppercase letter. 2. The next three characters are digits between 0 and 9. 3. The next four characters are lowercase letters. 4. The last two characters are either the special cha...
Here is the Python code to solve the given problem in the markdown block: ```python import random import string def generate_random_sequence() -> str: """ Generates a random sequence of 10 characters according to the following rules: 1. The first character is always an uppercase letter. 2. The next thr...
python_sharegpt_23k
21,270
Write a Python function to calculate the average release year of movies from a given dataset. The dataset is a list of dictionaries, where each dictionary represents a movie and contains keys for the movie title, director, and release year. The function should handle cases where the dataset might be empty. The code sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def average_release_year(movies: List[Dict[str, any]]) -> float: """ Calculate the average release year of movies from a given dataset. Args: movies (List[Dict[str, any]]): A list of d...
python_sharegpt_23k
21,274
Write a Python function to calculate the average of a list of odd numbers. The function should handle the input validation to ensure all elements in the list are odd numbers. If any element is not odd, the function should return `None`. The code should start with: ```python from typing import List, Optional def calcul...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def calculate_average_of_odds(numbers: List[int]) -> Optional[float]: """ Calculate the average of a list of odd numbers. Args: numbers (List[int]): A list of integers. Return...
python_sharegpt_23k
21,278
Write a Python function to categorize a list of sentiment scores into three levels: mildly positive (score 70-79), moderately positive (score 80-89), and highly positive (score 90-100). The function should return a dictionary with the count of text inputs falling into each sentiment category. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def categorize_sentiments(sentiments: List[int]) -> Dict[str, int]: """ Categorizes a list of sentiment scores into three levels: mildly positive, moderately positive, and highly positive. Arg...
python_sharegpt_23k
21,286
Write a Python function to calculate the total revenue given the number of units sold and the price per unit. The function should be able to handle both integer and float inputs for the `num_units` and `price_per_unit` parameters. The code should start with: ```python def calculate_revenue(num_units: float, price_per_u...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_revenue(num_units: float, price_per_unit: float) -> float: """ Calculate the total revenue given the number of units sold and the price per unit. Args: num_units (float): The number of units sold. Can ...
python_sharegpt_23k
21,302
Write a Python function to filter out all odd numbers from a given list and then sort the remaining even numbers in descending order. The function should return the sorted list of even numbers. The code should start with: ```python from typing import List def sort_evens_descending(arr: List[int]) -> List[int]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_evens_descending(arr: List[int]) -> List[int]: """ Filters out all odd numbers from the input list and sorts the remaining even numbers in descending order. Args: arr (List[int]): T...
python_sharegpt_23k
21,309
Write a Python function to calculate the age of a person when they completed a significant work given their birth year and the year they completed the work. The function should return the age as an integer. The code should start with: ```python def calculate_age_at_completion(birth_year: int, completion_year: int) -> ...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_age_at_completion(birth_year: int, completion_year: int) -> int: """ Calculate the age of a person at the time they completed a significant work. Args: birth_year (int): The birth year of the person. ...
python_sharegpt_23k
21,316
Write a Python function to evaluate a list of mathematical expressions consisting of numbers and the operators `+`, `-`, `*`, `/`, and parentheses. The function should return a list of integers, where each integer is the result of evaluating the corresponding expression. The code should start with: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def evaluate_expressions(expressions: List[str]) -> List[int]: """ Evaluate a list of mathematical expressions and return the results as a list of integers. Args: expressions (List[str]): A ...
python_sharegpt_23k
21,319
Write a Python function to randomly generate a list of five rare items, one from each category. The categories and their corresponding items are predefined. The function should ensure that each item is unique and belongs to a different category. The code should start with: ```python from typing import List import rando...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_rare_items() -> List[str]: """ Generates a list of five rare items, one from each predefined category. Returns: List[str]: A list containing five unique rare items...
python_sharegpt_23k
21,320
Write a Python function to find the highest and lowest values for each attribute in a given dataset. The dataset is represented as a 2D NumPy array where each row represents a record and each column represents a numerical attribute. The function should return two lists: one for the highest values and one for the lowest...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def find_extremes(dataset: np.ndarray) -> (List[float], List[float]): """ Find the highest and lowest values for each attribute in a given dataset. Args: dataset (np.ndarr...
python_sharegpt_23k
21,327
Write a Python function to generate a random sci-fi protagonist's character profile. The profile should include the following attributes: Name (string), Age (integer between 25 and 50), Gender (either "male" or "female"), Species (string), Occupation (string), Strength (integer between 1 and 8), Intelligence (integer b...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import random def generate_character_profile() -> Dict[str, str]: """ Generates a random sci-fi protagonist's character profile. Returns: Dict[str, str]: A dictionary containing the characte...
python_sharegpt_23k
21,329
Write a Python function to calculate the Euclidean distance between two points in a 2D plane, ensuring that the result is accurate up to two decimal places. The function should handle any floating-point inputs for the coordinates. The code should start with: ```python import math def euclidean_distance(x1: float, y1:...
Here is the Python code to solve the given problem in the markdown block: ```python import math def euclidean_distance(x1: float, y1: float, x2: float, y2: float) -> float: """ Calculate the Euclidean distance between two points (x1, y1) and (x2, y2) in a 2D plane, ensuring the result is accurate up to two...
python_sharegpt_23k
21,334
Write a Python function to generate the nth number in the Fibonacci sequence using a tail-recursive approach. The Fibonacci sequence is a series of numbers where each number is the sum of the two preceding ones, starting from 0 and 1. The function should handle the base cases where n is less than or equal to 1 by retur...
Here is the Python code to solve the given problem in the markdown block: ```python def fibonacci_tail_recursive(n: int) -> int: """ Generate the nth number in the Fibonacci sequence using a tail-recursive approach. The Fibonacci sequence is a series of numbers where each number is the sum of the two prece...
python_sharegpt_23k
21,347
Write a Python function to calculate the sum of even numbers in a given list of integers. The function should handle edge cases such as empty lists, non-integer values, and negative numbers. The function should complete the task in linear time and space complexity. The code should start with: ```python from typing imp...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(numbers: List[int]) -> int: """ Calculate the sum of even numbers in a given list of integers. Args: numbers (List[int]): A list of integers. Returns: in...
python_sharegpt_23k
21,355
Write a Python function to calculate the nth Fibonacci number using dynamic programming with memoization. The function should efficiently handle large values of n by storing previously computed results to avoid redundant calculations. Additionally, create a table that compares and contrasts the time and space complexit...
Here is the Python code to solve the given problem in the markdown block: ```python def fibonacci_memo(n: int, memo: dict = {}) -> int: """ Calculate the nth Fibonacci number using dynamic programming with memoization. Args: n (int): The position in the Fibonacci sequence to calculate. memo...
python_sharegpt_23k
21,356
Write a Python function to generate a list of prime numbers up to a given integer `n` efficiently. The function should correctly identify prime numbers and return a list of all prime numbers less than or equal to `n`. The code should start with: ```python from typing import List def generate_primes(n: int) -> List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import math def generate_primes(n: int) -> List[int]: """ Generate a list of all prime numbers less than or equal to a given integer `n`. Args: n (int): The upper limit to generate prime num...
python_sharegpt_23k
21,365
Write a Python function to generate a random French musical term from a predefined list of terms. The function should return the randomly selected term as a string. The code should start with: ```python from typing import List import random def generate_random_french_term(terms: List[str]) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_random_french_term(terms: List[str]) -> str: """ Generates a random French musical term from a given list of terms. Args: terms (List[str]): A list of French music...
python_sharegpt_23k
21,366
Write a Python function to determine if a given number is a prime number. A prime number is a natural number greater than 1 that has no positive divisors other than 1 and itself. The function should return `True` if the number is prime and `False` otherwise. The code should start with: ```python def is_prime_number(n: ...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime_number(n: int) -> bool: """ Determine if a given number is a prime number. Args: n (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
python_sharegpt_23k
21,367
Write a Python function to find the second smallest number in a list of integers without using any built-in functions or libraries. The function should handle duplicates and still return the second smallest number. The list is provided as input. The code should start with: ```python from typing import List def find_se...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_second_smallest(numbers: List[int]) -> int: """ Find the second smallest number in a list of integers without using any built-in functions or libraries. Args: numbers (List[int]): T...
python_sharegpt_23k
21,375
Write a Python function to calculate the total bill for a group of N people ordering from a restaurant, including the discount applied based on the number of people in the group. The discount rules are as follows: - For a group of 2-3 people, they get a 5% discount. - For a group of 4-6 people, they get a 10% discount....
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_total_bill_with_discount(num_people: int, total_bill: float) -> float: """ Calculate the total bill for a group of N people ordering from a restaurant, including the discount applied. Args: num_people ...
python_sharegpt_23k
21,381
Write a Python function to find the sum of all even numbers from 1 to `n` and output the even numbers used in the calculation. Additionally, the program should only execute in O(log n) time complexity using a binary search algorithm. The output should also include the total number of even integers used in the calculati...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def binary_search(arr: List[int], x: int) -> int: """ Perform a binary search to find the index of the largest number in arr that is less than or equal to x. Args: arr (List[int]): Th...
python_sharegpt_23k
21,384
Write a Python function to compute the summation of the first `n` natural numbers. The function should take an integer `n` as input and return the sum of the first `n` natural numbers. The code should start with: ```python def sum_of_first_n_numbers(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_first_n_numbers(n: int) -> int: """ Compute the summation of the first n natural numbers. Args: n (int): The number of natural numbers to sum. Returns: int: The sum of the first n natural num...
python_sharegpt_23k
21,387
Write a Python function to implement a sorting algorithm that has a space complexity of O(1) and can handle duplicates in the input without affecting the time or space complexity. The sorting algorithm should maintain the same requirements as the previous prompt. The code should start with: ```python from typing impor...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def cycle_sort(array: List[int]) -> List[int]: """ Sorts the given array using Cycle Sort with a space complexity of O(1) and handles duplicates. Args: array (List[int]): The array to be sor...
python_sharegpt_23k
21,392
Write a Python function to generate a randomized free verse poem that evokes the bittersweet emotion of nostalgia and includes at least four different sensory details related to a specific childhood memory. The function should randomly select sensory details and a nostalgic word, and then construct a poem based on a ra...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_nostalgic_poem(sensory_details: List[str], nostalgic_words: List[str], poem_structures: List[str]) -> str: """ Generates a randomized free verse poem that evokes the bitterswee...
python_sharegpt_23k
21,402
Write a Python function to generate all Narcissistic numbers within a given range `[start, end]`. A Narcissistic number (also known as a pluperfect number, Armstrong number, or pluperfect digital invariant) is a number that is the sum of its own digits each raised to the power of the number of digits. The function sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_narcissistic_numbers(start: int, end: int) -> List[int]: """ Generate all Narcissistic numbers within the given range [start, end]. A Narcissistic number is a number that is the sum of its ...
python_sharegpt_23k
21,413
Write a Python function to calculate the total number of human legs on three distinct boats, each containing different numbers of pirates and sailors. The function should accept three dictionaries, each representing a boat with keys 'pirates' and 'sailors', and return a human-readable string summarizing the total numbe...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def calculate_total_legs(boats: List[Dict[str, int]]) -> str: """ Calculate the total number of human legs on three distinct boats. Args: boats (List[Dict[str, int]]): A list of dictio...
python_sharegpt_23k
21,418
Write a Python function to calculate the conditional probability of drawing a two on the second draw from a standard deck of 52 cards, given that the first draw was not a two. Additionally, calculate the joint probability of drawing two twos in a row on the first two draws. The function should simulate the card draws a...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import random def card_draw_probabilities() -> Tuple[float, float]: """ Calculate the conditional probability of drawing a two on the second draw given that the first draw was not a two, and the joi...
python_sharegpt_23k
21,434
Write a Python function to determine whether every string in an array is an anagram of every other string in the array. The function should handle arrays containing duplicate strings and use time and space-efficient algorithms. The function should be able to handle arrays of any length and complexity. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def are_all_anagrams(arr: List[str]) -> bool: """ Determines whether every string in the given array is an anagram of every other string in the array. Args: arr (List[str]): The array of str...
python_sharegpt_23k
21,445
Write a Python function to sort a dictionary of entities by their respective ID numbers in ascending order. The function should return a new dictionary with the sorted entities. The dictionary should contain the following entities and their respective ID numbers: - Alma WWTP: 55207 - Augusta SD: 57093 - Brinkley Water:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sort_entities_by_id(entities: Dict[str, int]) -> Dict[str, int]: """ Sorts a dictionary of entities by their respective ID numbers in ascending order. Args: entities (Dict[str, int]): A ...
python_sharegpt_23k
21,459
Write a Python function to remove all occurrences of a specified word from a given string. The function should handle multiple occurrences of the word and return the modified string. The code should start with: ```python def remove_all_occurrences(text: str, word: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def remove_all_occurrences(text: str, word: str) -> str: """ Removes all occurrences of a specified word from a given string. Args: text (str): The input string from which to remove the word. word (str): The...
python_sharegpt_23k
21,461
Write a Python function to perform a binary search on a sorted array of integers to find the index of a target integer. If the target integer is not found in the array, the function should return -1. The function should use the binary search algorithm to achieve this. The code should start with: ```python from typing ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def binary_search(arr: List[int], target: int) -> int: """ Perform a binary search on a sorted array to find the index of a target integer. Args: arr (List[int]): A sorted list of intege...
python_sharegpt_23k
21,473
Write a Python function to sort an array of strings in descending order based on the length of each string, while ensuring that only strings with lengths greater than or equal to 3 are included in the sorted array. The function should start with: ```python from typing import List def sort_strings_by_length_descending(...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_strings_by_length_descending(arr: List[str]) -> List[str]: """ Sorts an array of strings in descending order based on the length of each string, while ensuring that only strings with lengths...
python_sharegpt_23k
21,474
Write a Python function to sort a list of dictionaries based on a specific key in each dictionary. The function should take in two arguments: a list of dictionaries and a string representing the key to sort by. The dictionaries in the list will have the same keys, but the values may be of different data types. The func...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_dictionaries_by_key(dicts: List[Dict], key: str) -> List[Dict]: """ Sorts a list of dictionaries based on a specific key in each dictionary. Args: dicts (List[Dict]): A list o...
python_sharegpt_23k
21,476
Write a Python function to sort a dataset of fruits by their sweetness values in descending order and group them by their origin countries. Additionally, implement a function to calculate the average sweetness of fruits for each country. The dataset is represented as a dictionary where each key is a fruit name and the ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def sort_and_group_fruits(fruits: Dict[str, Dict[str, str]]) -> Dict[str, List[Tuple[str, int]]]: """ Sort the fruits by their sweetness values in descending order and group them by their or...
python_sharegpt_23k
21,488
Write a Python function to verify if all the circles in a given set of objects are blue. The set of objects is represented by a list `Z`, where each element `z_i` is a tuple of two integers. The first integer in the tuple represents the shape (1 for circle), and the second integer represents the color (3 for blue). The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def is_all_blue(Z: List[Tuple[int, int]]) -> bool: """ Verifies if all the circles in a given set of objects are blue. Args: Z (List[Tuple[int, int]]): A list of tuples where each tup...
python_sharegpt_23k
21,492
Write a Python function to reverse the words in a given string while maintaining the order of the words. For example, if the input string is "Hello world", the output should be "world Hello". The function should handle strings with multiple spaces between words and leading/trailing spaces. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python def reverse_words_in_string(s: str) -> str: """ Reverses the words in a given string while maintaining the order of the words. Args: s (str): The input string containing words to be reversed. Returns: s...
python_sharegpt_23k
21,502
Write a Python function to find the sunrise time for a specific date from a list of sunrise times and fill in the missing word in a sentence. The list of sunrise times is provided as strings in the format `'YYYY-MM-DD HH:MM:SS'`. The function should return the complete sentence with the missing word filled in. The cod...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import datetime def fill_missing_word(sunrise_times: List[str], target_date: str) -> str: """ Finds the sunrise time for a specific date from a list of sunrise times and fills in the missing word in a se...
python_sharegpt_23k
21,511
Write a Python function to reverse the characters in a given string and return the reversed string. The function should only use built-in Python functions and cannot use any third-party libraries or packages. The code should start with: ```python def reverse_string(word: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def reverse_string(word: str) -> str: """ Reverses the characters in the given string and returns the reversed string. Args: word (str): The string to be reversed. Returns: str: The reversed string. ...
python_sharegpt_23k
21,512
Write a Python function that converts all lowercase letters in a given string to uppercase using the ASCII table. The function should handle strings containing both lowercase and uppercase letters, as well as other characters (such as punctuation and spaces). The function should return the modified string with all lowe...
Here is the Python code to solve the given problem in the markdown block: ```python def convert_to_uppercase(s: str) -> str: """ Converts all lowercase letters in the given string to uppercase using the ASCII table. Args: s (str): The input string containing lowercase and uppercase letters, and pos...
python_sharegpt_23k
21,548
Write a Python function named `drastically_gradually` that takes a list of numbers as input and gradually increases each number by 5, then drastically decreases them by 10. The function should return the final list. The code should start with: ```python from typing import List def drastically_gradually(lst: List[int]...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def drastically_gradually(lst: List[int]) -> List[int]: """ Transforms a list of numbers by gradually increasing each number by 5, then drastically decreasing them by 10, and returns the final list. ...
python_sharegpt_23k
21,550
Write a Python function to compute the sum of the first n natural numbers. The function should be efficient and handle edge cases such as when n is 0 or negative. The code should start with: ```python def sum_of_natural_numbers(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_of_natural_numbers(n: int) -> int: """ Compute the sum of the first n natural numbers. Args: n (int): The number of natural numbers to sum. Returns: int: The sum of the first n natural numbers. ...
python_sharegpt_23k
21,554
Write a Python function to enforce gender-specific roles for family members in Armenian culture. The function should take a dictionary representing a family and modify it to include roles based on gender: males should be assigned the role of "breadwinner" and females should be assigned the role of "household". Children...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List def assign_roles(family: Dict) -> None: """ Assign gender-specific roles to family members in Armenian culture. Args: family (dict): A dictionary representing the family structure. ...
python_sharegpt_23k
21,561
Write a Python function to efficiently convert a comma-separated string of integers into a NumPy array. The function should handle any valid comma-separated integer string, including those with spaces between the commas and integers. The code should start with: ```python import numpy as np from typing import List def...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def string_to_numpy_array(int_string: str) -> np.ndarray: """ Converts a comma-separated string of integers into a NumPy array. Args: int_string (str): A string containing...
python_sharegpt_23k
21,563
Write a Python function to generate an HTML string that displays a sentence containing the words "blue", "apple", and "school". The word "apple" should be displayed in blue font color, while the words "blue" and "school" should be displayed in black font color. The function should accept three strings as input paramete...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_html_sentence(word1: str, word2: str, word3: str) -> str: """ Generates an HTML string that displays a sentence with specific words colored differently. Args: word1 (str): The first word to be displayed...
python_sharegpt_23k
21,566
Write a Python function to find and print all unique words that can be formed by rearranging the letters of one or more words in a given list. The function should handle duplicates and ignore case. The output should indicate which words are anagrams of each other. The code should start with: ```python from typing impo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_anagrams(words: List[str]) -> None: """ Finds and prints all unique words that can be formed by rearranging the letters of one or more words in a given list. Handles duplicates and ignores c...
python_sharegpt_23k
21,576
Write a Python function to search for a specific property in a JSON object and return the path to the property if it matches the given value. The function should be able to handle nested properties and arrays. The code should start with: ```python from typing import Dict, List, Any def find_property(data: Dict[str, An...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Any def find_property(data: Dict[str, Any], prop_name: str, prop_value: Any) -> List[Dict[str, str]]: """ Search for a specific property in a JSON object and return the path to the property if it ...
python_sharegpt_23k
21,582
Write a Python function to sort a list of fruit names based on the cumulative count of vowels in each fruit name, ensuring that the cumulative count increases progressively. The function should handle cases where the input list is empty or contains non-string elements by returning an empty list. The code should start w...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_fruits_by_cumulative_vowels(fruit_list: List[str]) -> List[str]: """ Sorts a list of fruit names based on the cumulative count of vowels in each fruit name. Args: fruit_list (List[s...
python_sharegpt_23k
21,591
Write a Python function to convert a given string to its hexadecimal representation and another function to decode a hexadecimal string back to its original string. The functions should handle UTF-8 encoded strings. The code should start with: ```python def string_to_hex(s: str) -> str: """ Convert a given str...
Here is the Python code to solve the given problem in the markdown block: ```python def string_to_hex(s: str) -> str: """ Convert a given string to its hexadecimal representation. Args: s (str): The input string to be converted. Returns: str: The hexadecimal representation of the input...
python_sharegpt_23k
21,603
Write a Python function to filter a list of retreat centers based on specific attributes such as location, budget, and duration. The function should return a list of retreat centers that match all the specified criteria. The code should start with: ```python from typing import List, Dict def filter_retreats(retreats_l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_retreats(retreats_list: List[Dict[str, any]], location: str, budget: int, duration: int) -> List[Dict[str, any]]: """ Filters a list of retreat centers based on specific attributes such ...
python_sharegpt_23k
21,607
Write a Python function to sort a list of food items in descending order based on their calorie content. Each food item is represented as a dictionary with keys `"name"` and `"calories"`. The function should return the sorted list. The code should start with: ```python from typing import List, Dict def sort_food_by_c...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_food_by_calories(food_list: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a list of food items in descending order based on their calorie content. Args: food_list (...
python_sharegpt_23k
21,616
Write a Python function to calculate and display the average yearly revenue of prepaid companies and T-Money for the past three years separately. Additionally, calculate the total number of customers for prepaid companies and T-Money for the past year and the average number of customers over the last three years for bo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def analyze_financial_data(revenue_data: List[List[float]], customer_data: List[List[int]]) -> None: """ Analyze and display the average yearly revenue and average number of customers for prepaid compani...
python_sharegpt_23k
21,629
Write a Python function to perform an algorithm with polynomial time complexity of O(n^2), where n is the length of the input list. The algorithm should sort a list of integers using the **Bubble Sort** method. The code should start with: ```python from typing import List def bubble_sort(numbers: List[int]) -> List[in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def bubble_sort(numbers: List[int]) -> List[int]: """ Sorts a list of integers using the Bubble Sort algorithm. Bubble Sort is a simple sorting algorithm that repeatedly steps through the list, ...
python_sharegpt_23k
21,631
Write a Python function to calculate the total sum of income of employees who meet the following criteria: 1. The employee is male. 2. The employee has a college degree. 3. The employee is aged between 25 and 30 (inclusive). 4. The employee works more than 40 hours a week. 5. The employee has been with the company for ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def calculate_total_income(employees: List[Dict[str, any]]) -> int: """ Calculate the total sum of income of employees who meet the specified criteria. Args: employees (List[Dict[str, ...
python_sharegpt_23k
21,637
Write a Python function to extract the expiration date and security code from a given credit card string. The credit card string is in the format "XXXX-XXXX-XXXX-XXXX MM/YY CVV", where "X" represents a digit, "MM/YY" is the expiration date in the format of a two-digit month and two-digit year, and "CVV" is a three-digi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import re def extract_credit_card_info(credit_card_string: str) -> Tuple[str, str]: """ Extracts the expiration date and security code from a given credit card string. Args: credit_card_str...
python_sharegpt_23k
21,640
Write a Python function to recommend the most effective treatment for individuals based on their occupation and BMI. The function should take in the following parameters: - A dictionary where the keys are medical conditions and the values are lists of treatments (e.g., `{"Diabetes": ["Insulin", "Metformin"], "High bloo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Callable def recommend_treatment(conditions: Dict[str, List[str]], individuals: List[Dict], calculate_bmi: Callable[[float, float], float]) -> Dict[str, str]: """ Recommends the most effective tre...
python_sharegpt_23k
21,641
Write a Python function to determine and print "Output 2" if the value of `x` is greater than the value of `y`, otherwise print "Output 1". The function should take two integers as input and return the appropriate output string based on the comparison. The code should start with: ```python def determine_output(x: int,...
Here is the Python code to solve the given problem in the markdown block: ```python def determine_output(x: int, y: int) -> str: """ Determines the output string based on the comparison of two integers. Args: x (int): The first integer to compare. y (int): The second integer to compare. ...
python_sharegpt_23k
21,649
Write a Python function to sort a list of numbers using the merge sort algorithm. The function should recursively divide the list into halves until each sublist contains a single element, and then merge the sublists back together in sorted order. The code should start with: ```python from typing import List def merge_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def merge_sort(nums: List[int]) -> List[int]: """ Sorts a list of integers using the merge sort algorithm. Args: nums (List[int]): The list of integers to be sorted. Returns: Li...
python_sharegpt_23k
21,651
Write a Python function to evaluate a mathematical equation given in string format using the operator precedence rules provided in a table. The function should handle basic arithmetic operations: addition (`+`), subtraction (`-`), multiplication (`*`), division (`/`), and modulus (`%`). The operator precedence rules ar...
Here is the Python code to solve the given problem in the markdown block: ```python def evaluate_equation(equation: str) -> float: """ Evaluates a mathematical equation given in string format using the provided operator precedence rules. Args: equation (str): The equation to evaluate, with spaces s...
python_sharegpt_23k
21,661
Write a Python function to extract all bigrams (consecutive pairs of words) from a given text. The function should return a list of tuples where each tuple contains a pair of words. The code should start with: ```python from typing import List, Tuple def extract_bigrams(text: str) -> List[Tuple[str, str]]: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List, Tuple def extract_bigrams(text: str) -> List[Tuple[str, str]]: """ Extracts all bigrams (consecutive pairs of words) from the given text. Args: text (str): The input text from which to ex...
python_sharegpt_23k
21,665
Write a Python function to determine whether a given sentence is a pangram. A pangram is a sentence that contains every letter of the alphabet at least once. The function should take a string as input and return a boolean value indicating whether the string is a pangram or not. The code should start with: ```python de...
Here is the Python code to solve the given problem in the markdown block: ```python def is_pangram(sentence: str) -> bool: """ Determines whether a given sentence is a pangram. A pangram is a sentence that contains every letter of the alphabet at least once. Args: sentence (str): The sentence ...
python_sharegpt_23k
21,667
Write a Python function to determine which students in a given list are not considered intelligent. Each student is represented by a dictionary with keys "name" and "intelligence", where "intelligence" is a boolean value. The function should return a list of names of students who are not intelligent. The code should s...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def find_not_intelligent_students(students: List[Dict[str, any]]) -> List[str]: """ Determine which students in a given list are not considered intelligent. Args: students (List[Dict[s...
python_sharegpt_23k
21,669
Write a Python function to generate a 30-minute high-intensity interval training (HIIT) workout plan that incorporates running and cycling. The workout should consist of 5 cycles, each with a duration of 6 minutes. In each cycle, the client should alternate between running and cycling for 30 seconds each, with a 30-sec...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_hiit_workout_plan(): """ Generates a 30-minute high-intensity interval training (HIIT) workout plan that incorporates running and cycling. The workout consists of 5 cycles, each with a duration of 6 minutes. In...
python_sharegpt_23k
21,672
Write a Python function to modify the ingredient list of a traditional Italian tiramisu recipe to make it vegan while still retaining its classic taste. The function should replace non-vegan ingredients with their vegan alternatives. The code should start with: ```python from typing import List def make_tiramisu_vegan...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def make_tiramisu_vegan(ingredients: List[str]) -> List[str]: """ Modifies the ingredient list of a traditional Italian tiramisu recipe to make it vegan. Args: ingredients (List[str]): The o...
python_sharegpt_23k
21,675
Write a Python function to calculate the total distance traveled by birds over a given number of days. The function should take a list of integers representing the distances traveled each day and return the total distance. The code should start with: ```python from typing import List def calculate_total_distance(dist...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_total_distance(distances: List[int]) -> int: """ Calculate the total distance traveled by birds over a given number of days. Args: distances (List[int]): A list of integers rep...
python_sharegpt_23k
21,685
Write a Python function to filter a list of car dictionaries and return a list of cars that meet specific criteria. The criteria are: the car must be of the brand 'Toyota', the year must be greater than 2010, and the color must be 'red'. The function should be optimized to iterate through the list only once. The code ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def filter_red_toyotas(cars: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Filters a list of car dictionaries and returns a list of cars that meet the following criteria: - The car's brand...
python_sharegpt_23k
21,692
Write a Python function to filter activities based on their intensity level and duration. The function should take a list of activities and an intensity level as input and return a list of activities that match the given intensity level and have a duration less than 30 minutes. The intensity levels and corresponding ac...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def filter_activities(activity_list: List[str], intensity_level: str) -> List[str]: """ Filters activities based on their intensity level and duration. Args: activity_list (List[str]): A lis...
python_sharegpt_23k
21,696
Write a Python function to identify all prime numbers greater than a specified threshold from a given list of integers. The function should return a list of these prime numbers. The code should start with: ```python from typing import List def find_primes_greater_than(numbers: List[int], threshold: int) -> List[int]:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_prime(n: int) -> bool: """ Check if a number is prime. Args: n (int): The number to check. Returns: bool: True if the number is prime, False otherwise. """ if n <...
python_sharegpt_23k
21,697
Write a Python function to isolate the last 5 characters of each string in a list, but only for strings that contain only numeric characters. If a string contains any non-numeric characters, it should be ignored. The function should return a list of the isolated characters. The code should start with: ```python from t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def isolate_last_five_numeric(data: List[str]) -> List[str]: """ Isolates the last 5 characters of each string in the input list that contains only numeric characters. Args: data (...
python_sharegpt_23k
21,700
Write a Python function to determine if a certain element exists in a list and return its index if found, otherwise return -1. The function should be efficient and handle edge cases such as an empty list or the element not being present in the list. The code should start with: ```python from typing import List, Any d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Any def find_element_index(lst: List[Any], element: Any) -> int: """ Determine if a certain element exists in a list and return its index if found, otherwise return -1. Args: lst (List[Any]...
python_sharegpt_23k
21,708
Write a Python function to calculate the sum of all grades in a dictionary that contains student information. Each student's information is represented as a dictionary with keys "age" and "grade". The function should iterate through the dictionary values and sum up the "grade" values. The code should start with: ```pyt...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def sum_grades(students: Dict[str, Dict[str, int]]) -> int: """ Calculate the sum of all grades in a dictionary of student information. Args: students (Dict[str, Dict[str, int]]): A dictiona...
python_sharegpt_23k
21,713
Write a Python function to calculate the product of the sum of two lists and the difference of their sums. The function should take two lists of integers as input and return the calculated product. The code should start with: ```python from typing import List def product_of_sum_and_difference(list_a: List[int], list_b...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def product_of_sum_and_difference(list_a: List[int], list_b: List[int]) -> int: """ Calculate the product of the sum of two lists and the difference of their sums. Args: list_a (List[int]): ...
python_sharegpt_23k
21,722
Write a Python function to extend the given dictionary of abbreviations with additional abbreviations and their full names, and then print the abbreviations and their full names in alphabetical order. The function should start with: ```python def print_abbreviations(additional_abbreviations: dict) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python def print_abbreviations(additional_abbreviations: dict) -> None: """ Extends the given dictionary of abbreviations with additional abbreviations and prints them in alphabetical order. Args: additional_abbreviations ...
python_sharegpt_23k
21,739
Write a Python function to calculate the wattage of a bulb based on its voltage and amperage. Additionally, create a function to check if a bulb is compatible with a given socket by comparing the voltage of the bulb with the voltage rating of the socket. The code should start with: ```python def calculate_wattage(volta...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_wattage(voltage: float, amperage: float) -> float: """ Calculate the wattage of a bulb based on its voltage and amperage. Args: voltage (float): The voltage of the bulb. amperage (float): The a...
python_sharegpt_23k
21,755
Write a Python function to generate a formatted table of expense items and their corresponding amounts, including a total row. The function should accept two lists: one for expense items and another for their amounts. The function should return a formatted string that represents the table. The code should start with: ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_expense_table(expense_items: List[str], amounts: List[int]) -> str: """ Generates a formatted table of expense items and their corresponding amounts, including a total row. Args: ...
python_sharegpt_23k
21,759
Write a Python function that generates a LaTeX formula representing the sentence "She who enjoys jogging on the seashore" using a given subject. The function should also incorporate a table of synonyms for "run" and "beach" that it can utilize. The function should start with: ```python from typing import Dict def gene...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict import random def generate_latex_formula(subject: str, synonyms: Dict[str, list]) -> str: """ Generates a LaTeX formula representing the sentence "She who enjoys jogging on the seashore" using a given su...
python_sharegpt_23k
21,769
Write a Python function to calculate the sum of all integers in a given list. The function should handle lists of any length, including empty lists. The function should return the sum of the integers in the list. The code should start with: ```python from typing import List def calculate_sum(numbers: List[int]) -> in...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_sum(numbers: List[int]) -> int: """ Calculate the sum of all integers in the given list. Args: numbers (List[int]): A list of integers. Returns: int: The sum of al...
python_sharegpt_23k
21,777
Write a Python function to count the number of occurrences of a given character in a string. The function should be optimized for performance and should handle edge cases such as an empty string or a character that does not appear in the string. The code should start with: ```python def count_occurrences(string: str, c...
Here is the Python code to solve the given problem in the markdown block: ```python def count_occurrences(string: str, char: str) -> int: """ Counts the number of occurrences of a given character in a string. Args: string (str): The string in which to count the occurrences. char (str): The ...
python_sharegpt_23k
21,780
Write a Python function to generate a random sequence of 20 uppercase letters and 10 digits, segment the sequence into two distinct lists (one with letters and another with digits), and compute the total sum of ASCII values of the letters and digits in their respective lists. The function should return a tuple containi...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple import random def generate_and_segment_sequence() -> Tuple[int, int]: """ Generates a random sequence of 20 uppercase letters and 10 digits, segments the sequence into two distinct lists (one with lette...
python_sharegpt_23k
21,789
Write a Python function to generate a table with two columns: one for the iteration number and the other for the corresponding message. The message should be "Hello World" for the first four iterations, and "Hello World5" for the fifth iteration. The function should return a list of tuples, where each tuple contains th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def generate_hello_world_table() -> List[Tuple[int, str]]: """ Generates a table with two columns: one for the iteration number and the other for the corresponding message. The message is "Hel...
python_sharegpt_23k
21,800
Write a Python function to analyze a given 5x5 matrix of random integers between 0 and 9. The function should calculate and return the sum of the main diagonal, the sum of the secondary diagonal, the sums of each row, the sums of each column, the index of the row with the largest sum, and the index of the column with t...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np def analyze_matrix(matrix: np.ndarray) -> tuple: """ Analyze a 5x5 matrix of random integers between 0 and 9. Args: matrix (np.ndarray): A 5x5 NumPy array with random integers between 0 and 9. ...
python_sharegpt_23k
21,815
Write a Python function to find the highest number in a list of integers. The function should handle lists of any length and return an error message if the input list is empty or contains non-integer elements. If the input list contains duplicates, the function should return the highest duplicate value. The function sh...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_highest_number(my_list: List[int]) -> int or str: """ Find the highest number in a list of integers. Args: my_list (List[int]): The list of integers to search for the highest number...
python_sharegpt_23k
21,817
Write a Python function to generate a greeting message with a randomly selected name from a predefined list of names, and append an exclamation mark to the end of the greeting string. The function should return the greeting string. The code should start with: ```python from typing import List import random def genera...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_greeting(names: List[str]) -> str: """ Generates a greeting message with a randomly selected name from a list of names, and appends an exclamation mark to the end of the gr...
python_sharegpt_23k
21,823
Write a Python function to convert a given string to uppercase without using the built-in `upper()` or `capitalize()` methods. The function should handle all characters in the string, converting only lowercase letters to their uppercase counterparts while leaving other characters unchanged. The code should start with:...
Here is the Python code to solve the given problem in the markdown block: ```python def to_uppercase(string: str) -> str: """ Converts a given string to uppercase without using the built-in upper() or capitalize() methods. Args: string (str): The input string to be converted to uppercase. Retu...
python_sharegpt_23k
21,824
Write a Python function to find the product with the highest price from a given two-column table. The table is represented as a list of tuples, where each tuple contains a product name and its corresponding price. The function should return the name of the product with the highest price. The code should start with: ``...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_most_expensive_product(table: List[Tuple[str, float]]) -> str: """ Find the product with the highest price from a given table. Args: table (List[Tuple[str, float]]): A list o...
python_sharegpt_23k
21,826
Write a Python function to add a new planet to a given list of planets in the Solar System, ensuring that the new planet follows the naming convention of classical mythology and is within the specified distance range from the sun. The distance range is from 0.39 AU (the distance of Mercury) to 39.5 AU (the distance of ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def add_new_planet(planets: List[str], new_planet: str, distance: float) -> List[str]: """ Adds a new planet to the list of planets in the Solar System if it meets the specified criteria. Args: ...
python_sharegpt_23k
21,827
Write a Python function to return the absolute value of the larger input among two numeric inputs, supporting both negative numbers and decimals. The function should include detailed documentation, precise type annotations, and comprehensive error handling. The function should raise a `TypeError` if any input is not nu...
Here is the Python code to solve the given problem in the markdown block: ```python def max_abs(a: float, b: float) -> float: """ Returns the absolute value of the larger input among two numeric inputs. Parameters: a (float): A numeric input to compare. b (float): Another numeric input to compare. ...
python_sharegpt_23k
21,836
Write a Python function to generate a random story about a person embarking on a journey to find a dragon. The story should contain at least one encounter with the dragon, and you should use the `random` module to randomly select elements for the story. Additionally, use f-strings to format the story output. The functi...
Here is the Python code to solve the given problem in the markdown block: ```python import random from typing import List def generate_random_dragon_story() -> str: """ Generates a random story about a person embarking on a journey to find a dragon. The story includes elements such as the protagonist's na...
python_sharegpt_23k
21,837
Write a Python function to efficiently remove duplicate elements from a given list of integers while preserving the order of the remaining elements. The function should be optimized for both time and space complexity. The code should start with: ```python from typing import List def remove_duplicates(arr: List[int]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def remove_duplicates(arr: List[int]) -> List[int]: """ Removes duplicate elements from the given list of integers while preserving the order of the remaining elements. Args: arr (List[int])...
python_sharegpt_23k
21,841
Write a Python function that takes two lists of numbers as input: one containing all the odd numbers and the other containing all the even numbers. The function should return a new list that contains all the odd numbers in descending order followed by all the even numbers in ascending order. Additionally, the function ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_and_display_numbers(odd_numbers: List[int], even_numbers: List[int]) -> List[int]: """ Sorts the odd numbers in descending order and the even numbers in ascending order, then concatenates th...
python_sharegpt_23k
21,851
Write a Python function to find all pairs of elements from two given lists of natural numbers that sum up to a specified target value. Additionally, filter out pairs where both elements are not multiples of 3. The first list should have a length greater than or equal to the second list. The code should start with: ```...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def find_pairs_with_conditions(list1: List[int], list2: List[int], target: int) -> List[Tuple[int, int]]: """ Find all pairs of elements from two lists that sum up to a specified target value. ...
python_sharegpt_23k
21,864
Write a Python function to generate a greeting message with a randomly selected name from a predefined list of names. The function should append an exclamation mark to the end of the greeting string and return the resulting string. The code should start with: ```python from typing import List import random def generat...
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List import random def generate_greeting(names: List[str]) -> str: """ Generates a greeting message with a randomly selected name from the given list. Args: names (List[str]): A list of names t...