source
stringclasses
6 values
id
int64
0
111k
instruction
stringlengths
167
4.39k
response
stringlengths
244
6.1k
python_sharegpt_23k
16,996
Write a Python function to generate a classification puzzle involving nocturnal mammals that live in underground burrows in the African savannah. The function should return a nested dictionary containing information about the burrow dimensions and details about the mammals. The outer dictionary should include 'burrow d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def generate_classification_puzzle(mammals: List[Dict[str, str]]) -> Dict[str, str]: """ Generates a classification puzzle for nocturnal mammals that live in underground burrows in the African sava...
python_sharegpt_23k
16,999
Write a Python function to calculate the sum of even numbers from 1 to a given positive integer `n`. The function should handle edge cases such as `n` being 0 or 1. The code should start with: ```python def sum_even_numbers(n: int) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sum_even_numbers(n: int) -> int: """ Calculate the sum of even numbers from 1 to a given positive integer n. Args: n (int): The upper limit of the range (inclusive) for which to calculate the sum of even numbers...
python_sharegpt_23k
17,000
Write a Python function to determine if at least two of three given characters appear in the string "codeforces". The function should handle a variety of inputs and provide accurate responses. The code should start with: ```python def at_least_two_in_codeforces(chars: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python def at_least_two_in_codeforces(chars: str) -> bool: """ Determine if at least two of the three given characters appear in the string "codeforces". Args: chars (str): A string of exactly three characters to check for...
python_sharegpt_23k
17,006
Write a Python function to calculate both the average temperature and the median temperature of a given set of temperature values. The function should handle both even and odd lengths of the input list. The code should start with: ```python from typing import List def calculate_temperatures(temperature: List[float]) -...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_temperatures(temperature: List[float]) -> (float, float): """ Calculate the average and median temperatures from a given set of temperature values. Args: temperature (List[floa...
python_sharegpt_23k
17,007
Write a Python function to group students in a classroom based on their favorite subject among Math, Science, and English. The function should also sort the students within each subject group by their grade in descending order. The function should return a dictionary where the keys are the subjects and the values are l...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def group_and_sort_students_by_subject(students: List[Dict[str, any]]) -> Dict[str, List[Dict[str, any]]]: """ Groups students by their favorite subject and sorts them by their grade in descending ...
python_sharegpt_23k
17,012
Write a Python function to calculate the quotient of two integers and ensure that the decimal number obtained is both precise up to a minimum of three decimal places and falls within a specified narrow range. The function should also check if the quotient is accurate based on the given range. The code should start wit...
Here is the Python code to solve the given problem in the markdown block: ```python def check_quotient_accuracy(dividend: int, divisor: int, min_range: float, max_range: float) -> str: """ Calculate the quotient of two integers and check if it falls within a specified range. Args: dividend (int): T...
python_sharegpt_23k
17,014
Write a Python function named `substring_filter` that takes a list of strings and a substring as input. The function should return a new list containing only the strings from the input list that contain the specified substring. The function should be case-sensitive. The starter code is as follows: ```python from typin...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def substring_filter(string_list: List[str], substring: str) -> List[str]: """ Filters a list of strings to return only those that contain a specified substring. Args: string_list (List[str]...
python_sharegpt_23k
17,018
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should filter out the even numbers from the list, sum them up, and return the total sum. The code should start with: ```python from typing import List def sum_of_even_numbers(numbers: List[int]) -> int: ```
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 all even numbers in the given list. Args: numbers (List[int]): A list of integers from which to calculate the sum...
python_sharegpt_23k
17,019
Write a Python function to perform a series of arithmetic operations on three given integers `a`, `b`, and `c` and return the final result. The operations to be performed are: 1. Add `a` and `b`. 2. Multiply the result by 2. 3. Subtract `c` from the result. The code should start with: ```python def arithmetic_operatio...
Here is the Python code to solve the given problem in the markdown block: ```python def arithmetic_operations(a: int, b: int, c: int) -> int: """ Perform a series of arithmetic operations on three given integers and return the final result. The operations are: 1. Add `a` and `b`. 2. Multiply the re...
python_sharegpt_23k
17,021
Write a Python function to categorize a list of fruits into two groups based on their pH values. The function should take a dictionary where the keys are fruit names and the values are their pH values, and a threshold pH value. The function should return two lists: one for acidic fruits (pH value less than the threshol...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Tuple def categorize_fruits(fruits: Dict[str, float], threshold: float) -> Tuple[List[str], List[str]]: """ Categorizes a list of fruits into acidic and non-acidic based on their pH values. A...
python_sharegpt_23k
17,027
Write a Python function to extract the essential words "celebrate", "victory", "parade", and "tomorrow" from a given sentence using a regular expression. The function should be robust enough to handle variations in word order, punctuation, and capitalization. The code should start with: ```python from typing import Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_essential_words(sentence: str) -> List[str]: """ Extracts the essential words "celebrate", "victory", "parade", and "tomorrow" from a given sentence. Args: sentence (st...
python_sharegpt_23k
17,036
Write a Python function to perform integer division and return both the quotient and the remainder. The function should take two parameters: the dividend and the divisor. The function should handle both positive and negative values for the dividend and divisor. The code should start with: ```python def integer_division...
Here is the Python code to solve the given problem in the markdown block: ```python def integer_division(dividend: int, divisor: int) -> tuple: """ Perform integer division and return both the quotient and the remainder. Args: dividend (int): The number to be divided. divisor (int): The num...
python_sharegpt_23k
17,046
Write a Python function to classify a list of animals into mammals and non-mammals, and further classify the mammals into nocturnal and non-nocturnal creatures. The function should return a dictionary where the keys are the animal names and the values are tuples indicating whether the animal is a mammal and whether it ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict, Tuple def classify_animals(animals: List[str]) -> Dict[str, Tuple[bool, bool]]: """ Classify a list of animals into mammals and non-mammals, and further classify the mammals into nocturnal and non...
python_sharegpt_23k
17,047
Write a Python function to calculate the sum of all odd numbers in a given list of integers. If the input list contains only even numbers, the function should return 0. The function should start with: ```python from typing import List def sum_of_odds(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python from typing import List def sum_of_odds(numbers: List[int]) -> int: """ Calculate the sum of all odd numbers in the given list. Args: numbers (List[int]): A list of integers. Returns: int: The sum of...
python_sharegpt_23k
17,060
Write a Python function to generate a random historical figure joke from a predefined list of jokes. The function should randomly select one joke from the list and return it as a string. The list should include at least 10 jokes involving various historical figures. 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 import random def get_random_historical_joke() -> str: """ Generates a random historical figure joke from a predefined list of jokes. Returns: str: A randomly selected joke involving a histo...
python_sharegpt_23k
17,061
Write a Python function to calculate the center of mass of an array of three-dimensional points. Each point is represented as a list of three integers, and the mass of each point is assumed to be equal. The function should return the center of mass as a list of three floats. The code should start with: ```python from ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_center_of_mass(points: List[List[int]]) -> List[float]: """ Calculate the center of mass of an array of three-dimensional points. Args: points (List[List[int]]): A list of thre...
python_sharegpt_23k
17,067
Write a Python function to test for Schur's inequality of degree 4. Schur's inequality states that for non-negative real numbers \(a\), \(b\), \(c\), and \(d\), the following inequality holds: \[ a^4 + b^4 + c^4 + d^4 + 2abcd \geq a^2bc + ab^2c + abc^2 + abcd \] The function should take four non-negative real numbers a...
Here is the Python code to solve the given problem in the markdown block: ```python def schurs_inequality_degree_4(a: float, b: float, c: float, d: float) -> bool: """ Test for Schur's inequality of degree 4 for given non-negative real numbers a, b, c, and d. Schur's inequality for degree 4 states: a^4...
python_sharegpt_23k
17,070
Write a Python function to perform a Caesar cipher encryption on a given string. The Caesar cipher shifts each letter in the string by a specified number of positions down the alphabet. The function should handle both uppercase and lowercase letters, preserving their case, and leave non-alphabetic characters unchanged....
Here is the Python code to solve the given problem in the markdown block: ```python def caesar_cipher_encrypt(text: str, shift: int) -> str: """ Encrypts the given text using a Caesar cipher with the specified shift. Args: text (str): The text to be encrypted. shift (int): The number of pos...
python_sharegpt_23k
17,077
Write a Python function to find the most recent date from a list of dates in the format "YYYY-MM-DD". The function should take a list of date strings as input and return the most recent date as a string. The code should start with: ```python from typing import List def get_most_recent_date(dates: List[str]) -> str: `...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def get_most_recent_date(dates: List[str]) -> str: """ Find the most recent date from a list of dates in the format "YYYY-MM-DD". Args: dates (List[str]): A list of date strings in the forma...
python_sharegpt_23k
17,080
Write a Python function to implement a merge sort algorithm that can handle arrays containing both positive and negative integers. The function should have a time complexity of O(n log n). The code should start with: ```python from typing import List def merge_sort(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 merge_sort(arr: List[int]) -> List[int]: """ Sorts an array of integers using the merge sort algorithm. Args: arr (List[int]): The array of integers to be sorted. Returns: L...
python_sharegpt_23k
17,086
Write a Python function to generate a complex math puzzle using specific symbols and operators, and then solve it to find the correct answer. The puzzle should involve multiple steps of mathematical operations, using symbols that denote specific values. The function should return both the generated puzzle and its solut...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Tuple, Dict import random def generate_and_solve_puzzle(difficulty: int) -> Tuple[str, int]: """ Generates a complex math puzzle using specific symbols and operators, and solves it to find the correct answer....
python_sharegpt_23k
17,092
Write a Python function to determine whether two given strings are anagrams of each other. Two strings are considered anagrams if they contain the same characters with the same frequencies, regardless of their order. The function should be case-insensitive and should ignore spaces. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python def are_anagrams(str1: str, str2: str) -> bool: """ Determine whether two given strings are anagrams of each other. Args: str1 (str): The first string to compare. str2 (str): The second string to compare. ...
python_sharegpt_23k
17,094
Write a Python function to find all unique triplets in a given array that sum up to a specified target. The function should return a list of lists, where each inner list contains three integers that sum to the target. The array may contain duplicate elements, but the solution should not contain duplicate triplets. The...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def three_sum_to_target(arr: List[int], target: int) -> List[List[int]]: """ Find all unique triplets in the array that sum up to the specified target. Args: arr (List[int]): The input array...
python_sharegpt_23k
17,104
Write a Python function to generate a table of outputs for a given range of values of `x` from 0 to `n` (inclusive), where `n` is a non-negative integer. The function should print different messages based on the value of `x` as follows: - If `x` is less than 5, print "x is less than 5". - If `x` is equal to 5, print "x...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_output_table(n: int) -> None: """ Generates a table of outputs for values of x from 0 to n (inclusive). Prints different messages based on the value of x: - If x is less than 5, prints "x is less than 5". ...
python_sharegpt_23k
17,109
Write a Python function to count the number of each vowel in a given sentence and store the counts in a dictionary. The function should be case-insensitive, meaning it should treat 'A' and 'a' as the same vowel. The output dictionary should have vowels as keys and their respective counts as values. The code should sta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_vowels(sentence: str) -> Dict[str, int]: """ Counts the number of each vowel in a given sentence and returns the counts in a dictionary. Args: sentence (str): The input sentence in...
python_sharegpt_23k
17,112
Write a Python function to convert a list of phone numbers from the format "(XXX) XXX-XXXX" to the format "XXX-XXX-XXXX". The input should be a list of phone numbers in the original format, and the output should be a list of phone numbers in the new format. The function should handle any valid input in the specified fo...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def convert_phone_numbers(phone_numbers: List[str]) -> List[str]: """ Converts a list of phone numbers from the format "(XXX) XXX-XXXX" to "XXX-XXX-XXXX". Args: phone_numbers (List[str]): A ...
python_sharegpt_23k
17,129
Write a Python function to calculate the height of an equilateral triangle given the length of one side. The function should use the mathematical formula for the height of an equilateral triangle, which is derived from the Pythagorean theorem. The code should start with: ```python import math def calculate_height_of_e...
Here is the Python code to solve the given problem in the markdown block: ```python import math def calculate_height_of_equilateral_triangle(side_length: float) -> float: """ Calculate the height of an equilateral triangle given the length of one side. Args: side_length (float): The length of one ...
python_sharegpt_23k
17,131
Write a Python function to find and return the second largest integer in a given array of non-repeating integers. The array is guaranteed to have at least two elements. The code should start with: ```python from typing import List def find_second_largest(arr: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_second_largest(arr: List[int]) -> int: """ Find and return the second largest integer in a given array of non-repeating integers. Args: arr (List[int]): The array of non-repeating i...
python_sharegpt_23k
17,135
Write a Python function to calculate the sum of all odd numbers in a given list of integers. The function should handle lists of any length and should return the sum of the odd numbers. The code should start with: ```python from typing import List def sum_of_odd_numbers(numbers: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_odd_numbers(numbers: List[int]) -> int: """ Calculate the sum of all odd numbers in the given list. Args: numbers (List[int]): A list of integers. Returns: int: The s...
python_sharegpt_23k
17,137
Write a Python function to check if a given string contains at least two occurrences of the substring "ABC". The function should use regular expressions to perform this check. The code should start with: ```python import re def contains_at_least_two_abc(string: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python import re def contains_at_least_two_abc(string: str) -> bool: """ Check if the given string contains at least two occurrences of the substring "ABC". Args: string (str): The string to be checked. Returns: ...
python_sharegpt_23k
17,145
Write a Python function to calculate the sum of all even numbers in a given list of integers. The function should iterate through the list at least twice to ensure that the sum is calculated correctly. The code should start with: ```python from typing import List def sum_of_even_numbers(nums: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_of_even_numbers(nums: List[int]) -> int: """ Calculate the sum of all even numbers in a given list of integers. Args: nums (List[int]): A list of integers from which to calculate the...
python_sharegpt_23k
17,149
Implement a modified version of the bubble sort algorithm that terminates early if the array is already sorted. Additionally, the sorting algorithm should be optimized to have a time complexity of O(n) when the input array is already sorted in ascending order, where n is the length of the input array. The function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def optimized_bubble_sort(arr: List[int]) -> List[int]: """ Sorts the input list using a modified bubble sort algorithm that terminates early if the array is already sorted. This optimization ensures...
python_sharegpt_23k
17,158
Write a Python function to clean a given serial number string by removing extra spaces and special characters (like hyphens and periods) while ensuring that valuable information is not accidentally deleted. The function should return the cleaned serial number string. The code should start with: ```python import re de...
Here is the Python code to solve the given problem in the markdown block: ```python import re def clean_serial_number(serial_num: str) -> str: """ Cleans a given serial number string by removing extra spaces and special characters. Args: serial_num (str): The serial number string to be cleaned. ...
python_sharegpt_23k
17,162
Write a Python function to generate a haiku with a specific theme or subject. The haiku should follow the traditional 5-7-5 syllable structure and must include the specified theme in the generated haiku. The function should start with: ```python from typing import List def generate_haiku_with_theme(theme: 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_haiku_with_theme(theme: str) -> str: """ Generates a haiku with a specific theme. The haiku follows the traditional 5-7-5 syllable structure. Args: theme (str): Th...
python_sharegpt_23k
17,164
Write a Python function to classify a given list of plant names into either "Gymnosperm" or "Angiosperm" based on predefined characteristics. The function should return a dictionary where the keys are the plant names and the values are their classifications. The code should start with: ```python from typing import List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def classify_plants(plant_names: List[str]) -> Dict[str, str]: """ Classify a list of plant names into either "Gymnosperm" or "Angiosperm" based on predefined characteristics. Args: pl...
python_sharegpt_23k
17,165
Write a Python function to find the intersection of two given lists. The intersection should return a list of elements that are present in both input lists, without duplicates and in the order they appear in the first list. The code should start with: ```python from typing import List def find_intersection(list1: Lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def find_intersection(list1: List[int], list2: List[int]) -> List[int]: """ Find the intersection of two lists, returning a list of elements that are present in both input lists, without duplicates a...
python_sharegpt_23k
17,167
Write a Python function to calculate the error between the computed sum of two units and the theoretical value of two, given a range of values for the constants `a` and `b`. The function should generate a table with twenty or more values of `a` and `b`, compute the error for each pair, and return the table as a list of...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_error_table(start: float, end: float, step: float) -> List[Tuple[float, float, float, float, float]]: """ Calculate the error between the computed sum of two units and the theoretica...
python_sharegpt_23k
17,173
Write a Python function to compute the sum of even numbers in a given list and print a formatted table displaying the values of the list along with the computed sum of even numbers. The function should start with: ```python from typing import List def sum_even_numbers_and_print_table(data: List[int]) -> None: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sum_even_numbers_and_print_table(data: List[int]) -> None: """ Computes the sum of even numbers in the given list and prints a formatted table. Args: data (List[int]): The list of intege...
python_sharegpt_23k
17,174
Write a Python function to generate a random string of a specified length using a combination of uppercase letters, lowercase letters, and digits. The function should allow the user to optionally specify the characters to be included in the random string. If no characters are specified, the function should use the defa...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Optional, List import random import string def generate_random_string(length: int, characters: Optional[List[str]] = None) -> str: """ Generates a random string of the specified length using the specified cha...
python_sharegpt_23k
17,177
Write a Python function to evaluate the self-confidence, self-awareness, and self-stability of a person based on their properties in a dictionary. The function should return a string describing the person's characteristics based on the given conditions. The code should start with: ```python def evaluate_person(person:...
Here is the Python code to solve the given problem in the markdown block: ```python def evaluate_person(person: dict) -> str: """ Evaluates the self-confidence, self-awareness, and self-stability of a person based on their properties. Args: person (dict): A dictionary containing the properties of t...
python_sharegpt_23k
17,184
Write a Python function to generate a sorted list of unique integers in descending order from a given list of integers. The function should ensure that the resulting list contains only unique elements and is sorted in descending order. The code should start with: ```python from typing import List def generate_sorted_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_sorted_unique_list(input_list: List[int]) -> List[int]: """ Generates a sorted list of unique integers in descending order from a given list of integers. Args: input_list (List[...
python_sharegpt_23k
17,188
Write a Python function to count the number of letters in a given word without using the built-in function `len()`. The input string will always contain a word in English. The function should iterate through each character in the string and count the number of characters that are letters. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python def count_letters(word: str) -> int: """ Counts the number of letters in a given word without using the built-in function 'len()'. Args: word (str): The input word in English. Returns: int: The number o...
python_sharegpt_23k
17,196
Write a Python function to filter out specific words from permit/deny statements in route-maps and print only the statements that do not contain the filtered words. The function should handle multiple route-maps and ensure that it can filter out multiple words provided by the user. The code should start with: ```pytho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, List, Set def filter_route_maps(route_maps: Dict[str, List[str]], filtered_words: Set[str]) -> None: """ Filters out specific words from permit/deny statements in route-maps and prints only the statemen...
python_sharegpt_23k
17,197
Write a Python function to generate a specified number of unique blog post topics from a given list of topics. The function should ensure that each generated topic is unique and not repeated within the specified number of topics. The code should start with: ```python from typing import List import random def generate_...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def generate_unique_post_topics(post_topics: List[str], num_topics: int) -> List[str]: """ Generates a specified number of unique blog post topics from a given list of topics. Args: ...
python_sharegpt_23k
17,198
Write a Python function to generate a sentence that demands an adverb for the verb "run" and produce an adverb for it. The function should return the sentence in LaTeX format. The code should start with: ```python from typing import List def generate_sentence_with_adverb(adverbs: 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_sentence_with_adverb(adverbs: List[str]) -> str: """ Generates a sentence that demands an adverb for the verb "run" and produces an adverb for it in LaTeX format. Args: ...
python_sharegpt_23k
17,199
Write a Python function to generate a sentence that includes a reference to a physical landmark. The function should accept a landmark name as an argument and return a formatted sentence. The sentence should be dynamically constructed using an f-string. The code should start with: ```python def generate_sentence(landm...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_sentence(landmark: str) -> str: """ Generates a sentence that includes a reference to a physical landmark. Args: landmark (str): The name of the physical landmark to be included in the sentence. Re...
python_sharegpt_23k
17,203
Write a Python function to return the absolute value of the larger input from two given numbers. The function should support both integers and floating-point numbers, handle negative numbers, and ensure that the inputs are valid numeric types. The function should raise a `TypeError` if the inputs are not numeric. The ...
Here is the Python code to solve the given problem in the markdown block: ```python def max_abs_val(num1: float, num2: float) -> float: """ Returns the absolute value of the larger input from two given numbers. Args: num1 (float): The first number to compare. num2 (float): The second number...
python_sharegpt_23k
17,208
Write a Python function to categorize a list of animals into those that live on land and those that live in water using a dictionary data structure. The function should take a list of animal names as input and return a dictionary with two keys: 'Land Animals' and 'Water Animals'. The values for these keys should be lis...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def categorize_animals(animals: List[str]) -> Dict[str, List[str]]: """ Categorizes a list of animals into those that live on land and those that live in water. Args: animals (List[str...
python_sharegpt_23k
17,217
Write a Python function to validate whether a given IP address is a valid IPv4 address. The function should return `True` if the IP address is valid and `False` otherwise. The IP address should be in the form of a string. The function should handle various edge cases, such as empty strings, incorrect formats, and inval...
Here is the Python code to solve the given problem in the markdown block: ```python def is_valid_ipv4(ip: str) -> bool: """ Validates whether a given string is a valid IPv4 address. Args: ip (str): The IP address to validate. Returns: bool: True if the IP address is valid, False otherw...
python_sharegpt_23k
17,221
Write a Python function to decrypt a message encoded with a Caesar cipher. The Caesar cipher is a type of substitution cipher where each letter in the plaintext is shifted a certain number of places down or up the alphabet. The function should take a ciphertext string and a key (an integer representing the number of po...
Here is the Python code to solve the given problem in the markdown block: ```python def caesar_cipher_decrypt(ciphertext: str, key: int) -> str: """ Decrypts a message encoded with a Caesar cipher. Args: ciphertext (str): The encrypted message to be decrypted. key (int): The number of posit...
python_sharegpt_23k
17,227
Write a Python function to find the largest number in a list of integers without using the built-in `max` function. The function should iterate through the list only once and handle edge cases such as an empty list or a list with only negative numbers. The code should start with: ```python from typing import List, Opti...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def find_largest_number(numbers: List[int]) -> Optional[int]: """ Find the largest number in a list of integers without using the built-in max function. The function iterates through the li...
python_sharegpt_23k
17,252
Write a Python function to sort a list of words in alphabetical order and concatenate them into a sentence. The function should handle lists of varying lengths and ensure that the resulting sentence is grammatically correct by placing the words in the correct order. The code should start with: ```python from typing im...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_words_to_sentence(words: List[str]) -> str: """ Sorts a list of words in alphabetical order and concatenates them into a sentence. Args: words (List[str]): A list of words to be sor...
python_sharegpt_23k
17,255
Write a Python function to count the occurrences of each character in a given string and return the result as a dictionary. The function should handle any string input, including empty strings and strings with special characters. The code should start with: ```python from typing import Dict def count_character_occurre...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def count_character_occurrences(s: str) -> Dict[str, int]: """ Count the occurrences of each character in the given string and return the result as a dictionary. Args: s (str): The input str...
python_sharegpt_23k
17,260
Write a Python function to calculate the sum of all odd numbers in a given list of integers. The function should iterate through the list, check if each number is odd, and if so, add it to the total sum. The function should return the total sum of all odd numbers. 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 sum_of_odds(numbers: List[int]) -> int: """ Calculate the sum of all odd numbers in the given list. Args: numbers (List[int]): A list of integers. Returns: int: The sum of a...
python_sharegpt_23k
17,277
Write a Python function to convert a list of books into a list of dictionaries. Each dictionary should contain specific information about a single book, including the book's title, author's name, genre, and publisher's name. The input to this function will be a list of lists, where each inner list represents a book wit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def convert_books_to_dict(book_list: List[List[str]]) -> List[Dict[str, str]]: """ Converts a list of books into a list of dictionaries. Each book in the input list is represented as a list of...
python_sharegpt_23k
17,281
Write a Python function to calculate the hypotenuse of a right triangle given the lengths of its two legs using the Pythagorean theorem. The function should take two arguments representing the lengths of the legs and return the length of the hypotenuse. The code should start with: ```python import math def calculate_h...
Here is the Python code to solve the given problem in the markdown block: ```python import math def calculate_hypotenuse(leg1: float, leg2: float) -> float: """ Calculate the hypotenuse of a right triangle given the lengths of its two legs. The Pythagorean theorem is used to calculate the hypotenuse: c = ...
python_sharegpt_23k
17,284
Write a Python function to validate an IPv4 address and determine its class based on the first octet. The function should return a tuple containing a boolean indicating whether the IP address is valid and a string representing the class of the IP address. The function should adhere to the following rules: - The IP addr...
Here is the Python code to solve the given problem in the markdown block: ```python def validate_ipv4(ip_address: str) -> tuple: """ Validates an IPv4 address and determines its class. Args: ip_address (str): The IP address to validate. Returns: tuple: A tuple containing a boolean indi...
python_sharegpt_23k
17,292
Write a Python function to create an array of a specified size filled with random numbers within a given range using the NumPy library. The function should return the generated array. The code should start with: ```python import numpy as np from typing import List def generate_random_array(size: int, low: int, high: ...
Here is the Python code to solve the given problem in the markdown block: ```python import numpy as np from typing import List def generate_random_array(size: int, low: int, high: int) -> List[int]: """ Generates an array of a specified size filled with random numbers within a given range. Args: s...
python_sharegpt_23k
17,294
Write a Python function to validate if a given email address follows the standard email format using regular expressions. The function should return `True` if the email is valid and `False` otherwise. The email validation should be based on the following criteria: - The email address must start with one or more alphanu...
Here is the Python code to solve the given problem in the markdown block: ```python import re def validate_email(email: str) -> bool: """ Validates if the given email address follows the standard email format using regular expressions. Args: email (str): The email address to validate. Returns...
python_sharegpt_23k
17,308
Write a Python function to expand the "Guri and Gura" book series by introducing a new character with a unique personality and integrating them into the existing plot. The function should modify the existing book series data structure to include the new character and update the plot of each book to showcase the new cha...
Here is the Python code to solve the given problem in the markdown block: ```python def expand_book_series(book_series: dict, new_character: dict) -> dict: """ Expands the "Guri and Gura" book series by introducing a new character and integrating them into the existing plot. Args: book_series (dict...
python_sharegpt_23k
17,321
Write a Python function to sort a list of objects by their color (in the order: red, green, blue) and then by their size (from small to large). Each object is represented as a dictionary with keys: `name`, `color`, `size`, and `rgb`. The function should return the sorted list of objects. Additionally, the function shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def sort_objects_by_color_and_size(objects: List[Dict[str, any]]) -> List[Dict[str, any]]: """ Sorts a list of objects by their color (in the order: red, green, blue) and then by their size (from s...
python_sharegpt_23k
17,325
Write a Python function to calculate the adjusted weights of backend servers for load balancing, considering their capacities and responsiveness. The function should penalize non-responsive servers by decreasing their weights and then restore their weights after a certain period. The code should start with: ```python f...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict def adjust_server_weights(servers: List[Dict[str, int]], non_responsive_server: str) -> List[Dict[str, int]]: """ Adjusts the weights of backend servers for load balancing, considering their capaci...
python_sharegpt_23k
17,332
Write a Python function to cancel meetings scheduled for the current week when the assistant is activated by the activation word "Abuela". The function should consider the scenario where the system needs to check the current week's meetings using the current local time of the user, and only cancel meetings in that week...
Here is the Python code to solve the given problem in the markdown block: ```python from datetime import datetime, timedelta def cancel_meetings(user_id: int, activation_word: str) -> str: """ Cancels meetings scheduled for the current week when the assistant is activated by the word "Abuela". Args: ...
python_sharegpt_23k
17,334
Write a Python function to predict customer churn based on given retention and churn rates. Additionally, create an OKR (Objective and Key Results) for reducing the churn rate by a specified percentage and suggest at least two key results to achieve this goal. The function should take the expected churn rate, actual ch...
Here is the Python code to solve the given problem in the markdown block: ```python def predict_customer_churn(expected_churn_rate: float, actual_churn_rate: float, reduction_goal: float) -> str: """ Predicts customer churn and sets an OKR for reducing the churn rate. Args: expected_churn_rate (flo...
python_sharegpt_23k
17,338
Write a Python function to calculate the product of all prime numbers in a given list of integers. The function should return 1 if there are no prime numbers in the list. The code should start with: ```python from typing import List def product_of_primes(lst: List[int]) -> int: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def is_prime(num: int) -> bool: """ Check if a number is prime. Args: num (int): The number to check for primality. Returns: bool: True if the number is prime, False otherwise. ...
python_sharegpt_23k
17,340
Write a Python function to generate a personalized letter of recommendation for an individual, incorporating their professional achievements, personal qualities, work ethic, and leadership abilities. The letter should be properly addressed to the intended recipient and include the recommender's contact information for ...
Here is the Python code to solve the given problem in the markdown block: ```python def generate_recommendation_letter(recipient: str, position: str, length_of_time: str, professional_achievements: str, personal_qualities: str, work_ethic_and_leadership_abilities: str, recommender_name: str, recommender_contact_info: s...
python_sharegpt_23k
17,341
Write a Python function to randomly select and return a case study from a given list of data analysis case studies. The function should ensure that the case study is chosen randomly each time it is called. The code should start with: ```python from typing import List def get_random_case_study(case_studies: List[str]) ...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def get_random_case_study(case_studies: List[str]) -> str: """ Randomly selects and returns a case study from the given list of data analysis case studies. Args: case_studies (...
python_sharegpt_23k
17,344
Write a Python function to convert a Roman numeral string to its decimal equivalent. The function should take a dictionary of Roman numeral symbols and their corresponding values, and a string representing the Roman numeral to be converted. The function should return the decimal equivalent of the Roman numeral. The co...
Here is the Python code to solve the given problem in the markdown block: ```python def roman_to_decimal(numerals: dict, input_numeral: str) -> int: """ Convert a Roman numeral string to its decimal equivalent. Args: numerals (dict): A dictionary mapping Roman numeral symbols to their integer value...
python_sharegpt_23k
17,351
Write a Python function to generate the first `k` terms of a quadratic sequence represented by the polynomial equation `n^2 + n + 1`, starting from `n=0`. The function should return a list of these terms. The code should start with: ```python from typing import List def generate_quadratic_sequence(k: int) -> List[int...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def generate_quadratic_sequence(k: int) -> List[int]: """ Generate the first k terms of a quadratic sequence represented by the polynomial equation n^2 + n + 1, starting from n=0. Args: k (i...
python_sharegpt_23k
17,357
Write a Python function to calculate the average of an array of integers. The function should handle empty arrays by returning `None` instead of attempting to divide by zero. The code should start with: ```python from typing import List, Optional def calculate_average(arr: List[int]) -> Optional[float]: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Optional def calculate_average(arr: List[int]) -> Optional[float]: """ Calculate the average of an array of integers. Args: arr (List[int]): The array of integers for which to calculate the...
python_sharegpt_23k
17,362
Write a Python program that includes several functions to perform mathematical operations on a list of numbers. The functions should be: 1. `get_sum(numbers)`: Returns the sum of the input numbers. If the input list is empty, it should return 0. 2. `get_average(numbers)`: Returns the average of the input numbers. If th...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Union, Optional def get_sum(numbers: List[Union[int, float]]) -> Union[int, float]: """ Returns the sum of a list of numbers. Args: numbers (List[Union[int, float]]): A list of numbers. ...
python_sharegpt_23k
17,363
Write a Python function to extract all email addresses from a given text string. The function should use regular expressions to identify and return a list of all valid email addresses found in the text. The code should start with: ```python from typing import List import re def extract_emails(text: str) -> List[str]:...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import re def extract_emails(text: str) -> List[str]: """ Extracts all valid email addresses from a given text string. Args: text (str): The text string from which to extract email addresses...
python_sharegpt_23k
17,368
Write a Python function to generate a random story about a frustrated robot navigating through a vast city where the AI systems are unreliable and causing chaos. The function should randomly select a scenario from a predefined list and return a formatted story string. 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 import random def generate_frustrated_robot_story(robot_name: str, city_name: str, scenarios: List[str]) -> str: """ Generates a random story about a frustrated robot navigating through a vast city with ...
python_sharegpt_23k
17,371
Write a Python function to generate an undirected, weighted, fully connected graph with a given number of nodes. Each node should contain two integers between 0 and 1000, representing X and Y coordinates. The edge weights should be the Euclidean distance between the nodes sharing that edge. Additionally, the graph shou...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple import random import math def generate_graph(num_nodes: int) -> Tuple[List[List[int]], List[Tuple[int, int]]]: """ Generates an undirected, weighted, fully connected graph with the given number of...
python_sharegpt_23k
17,372
Write a Python function to calculate the mean of a list of integers provided in a table format, where each number has a corresponding descriptive tag. The function should accept a list of tuples, where each tuple contains a number and its descriptive tag, and return the mean of the numbers. 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 calculate_mean(data: List[Tuple[int, str]]) -> float: """ Calculate the mean of a list of integers with corresponding descriptive tags. Args: data (List[Tuple[int, str]]): A list ...
python_sharegpt_23k
17,376
Write a Python function to merge two nested dictionaries into a single dictionary, ensuring that the type hints are correctly applied and the function handles optional values gracefully. The function should return the merged dictionary. If there are conflicting keys, the value from the second dictionary should overwrit...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Optional, Union def merge_nested_dicts( dict1: Dict[str, Union[Dict[str, int], Optional[int]]], dict2: Dict[str, Union[Dict[str, int], Optional[int]]] ) -> Dict[str, Union[Dict[str, int], Optional[int]]...
python_sharegpt_23k
17,387
Write a Python function that takes a list of tuples as input, where each tuple contains a string and an integer. The function should return a dictionary where the keys are the strings from the tuples and the values are the squares of the integers from the tuples. Additionally, the function should include error handling...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple, Dict def tuple_to_squared_dict(tuples: List[Tuple[str, int]]) -> Dict[str, int]: """ Converts a list of tuples into a dictionary where the keys are the strings from the tuples and the values ...
python_sharegpt_23k
17,388
Write a Python function to compute the quotient and remainder of a given number divided by 5, and then determine the highest remainder among a range of numbers. The function should also print the quotient and remainder for each number in the range. The code should start with: ```python def analyze_division_by_five(star...
Here is the Python code to solve the given problem in the markdown block: ```python def analyze_division_by_five(start: int, end: int) -> int: """ Analyzes the division of numbers in the given range by 5 and returns the highest remainder. Args: start (int): The starting number of the range (inclusi...
python_sharegpt_23k
17,407
Write a Python function to sort a list of words in alphabetical order, ignoring case and excluding duplicates. The function should take a list of strings as input and return a sorted list of unique words in lowercase. The code should start with: ```python from typing import List def sort_words_ignore_case(words: List...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def sort_words_ignore_case(words: List[str]) -> List[str]: """ Sorts a list of words in alphabetical order, ignoring case and excluding duplicates. Args: words (List[str]): A list of words t...
python_sharegpt_23k
17,426
Write a Python function to count the number of cars in a given list that have a fuel efficiency greater than 30 miles per gallon (mpg). The function should take a list of tuples as input, where each tuple contains the name of a car and its fuel efficiency in mpg. The function should return the count of cars that meet t...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def count_efficient_cars(cars: List[Tuple[str, int]]) -> int: """ Counts the number of cars with fuel efficiency greater than 30 miles per gallon (mpg). Args: cars (List[Tuple[str, in...
python_sharegpt_23k
17,432
Write a Python function to convert a list of items into a grammatically correct sentence. The sentence should start with "I have ", followed by the items separated by commas, and the last item should be preceded by "and". The sentence should end with " in my basket." 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 def items_to_sentence(items: List[str]) -> str: """ Converts a list of items into a grammatically correct sentence. Args: items (List[str]): A list of strings representing items. Return...
python_sharegpt_23k
17,434
Write a Python function to check if the first three elements of a given list of strings match the sequence ["A", "B", "C"]. The function should be optimized for performance and readability. The code should start with: ```python from typing import List def check_data(data: List[str]) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def check_data(data: List[str]) -> bool: """ Check if the first three elements of the given list match the sequence ["A", "B", "C"]. Args: data (List[str]): The list of strings to check. ...
python_sharegpt_23k
17,438
Write a Python function to generate the next number in a given sequence based on a mathematical pattern. The sequence provided is: 2, 6, 14, 30, 62. The function should identify the pattern and compute the next number in the sequence. The code should start with: ```python def next_number_in_sequence(previous_number: i...
Here is the Python code to solve the given problem in the markdown block: ```python def next_number_in_sequence(previous_number: int) -> int: """ Calculate the next number in the sequence based on the given pattern. The sequence follows the pattern where each number is obtained by multiplying the previous ...
python_sharegpt_23k
17,440
Write a Python function to calculate the absolute difference between the values of two mathematical expressions and display the resulting values in a formatted table. The expressions are `(2*3**4-1)` and `(5*5**2+8)`. The function should return the absolute difference and print the table. The code should start with: `...
Here is the Python code to solve the given problem in the markdown block: ```python def calculate_and_display_difference(): """ Calculate the absolute difference between the values of two mathematical expressions and display the resulting values in a formatted table. Returns: int: The absolute ...
python_sharegpt_23k
17,441
Write a Python function to determine if a given integer `n` is a prime number using the Sieve of Eratosthenes algorithm. The function should create a comprehensive table of all integers up to `n` and label all composites (non-primes) by identifying all multiples of each prime. Additionally, enhance the efficiency and p...
Here is the Python code to solve the given problem in the markdown block: ```python def is_prime(n: int) -> bool: """ Determines if a given integer `n` is a prime number using the Sieve of Eratosthenes algorithm. Args: n (int): The integer to check for primality. Returns: bool: True if...
python_sharegpt_23k
17,442
Write a Python function that generates a random idiom from a given list of idioms and returns both the idiom and its meaning. The function should handle a list of idioms and their meanings as a dictionary, where each key is the idiom and each value is its meaning. The function should randomly select an idiom from the d...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict, Tuple import random def get_random_idiom(idioms: Dict[str, str]) -> Tuple[str, str]: """ Randomly selects an idiom from a given dictionary of idioms and their meanings, and returns both the idiom and it...
python_sharegpt_23k
17,444
Write a Python function to encrypt a given string using the ROT13 cipher. The ROT13 cipher is a substitution cipher that replaces each letter with the letter 13 places down the alphabet. Non-alphabetic characters should remain unchanged. The code should start with: ```python def rot13_encrypt(message: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def rot13_encrypt(message: str) -> str: """ Encrypts a given string using the ROT13 cipher. The ROT13 cipher replaces each letter with the letter 13 places down the alphabet. Non-alphabetic characters remain unchanged. ...
python_sharegpt_23k
17,447
Write a Python function to compute the nth Fibonacci number using a recursive approach with memoization to improve performance. The function should start with: ```python def fibonacci_memoized(n: int, memo: dict = None) -> int: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def fibonacci_memoized(n: int, memo: dict = None) -> int: """ Compute the nth Fibonacci number using a recursive approach with memoization. Args: n (int): The position in the Fibonacci sequence to compute. ...
python_sharegpt_23k
17,449
Write a Python function that demonstrates the difference in outcome when using the `re.match` method instead of the `re.findall` method to extract all digit characters from a given string. The function should return a list of all digit characters found in the string. The code should start with: ```python import re fro...
Here is the Python code to solve the given problem in the markdown block: ```python import re from typing import List def extract_digits(test: str) -> List[str]: """ Extracts all digit characters from the given string using re.findall. Args: test (str): The input string from which to extract digit...
python_sharegpt_23k
17,450
Write a Python function to generate a military-style marching chant that includes words, numbers, and a consistent rhyming scheme. The function should take into consideration the user's desired chant length, tempo, and the number of syllables in each line of the chant. The output should be formatted as a table that sho...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Dict import random def generate_military_chant(chant_length: int, tempo: int, syllables_per_line: int) -> str: """ Generates a military-style marching chant with a consistent rhyming scheme. Args: ...
python_sharegpt_23k
17,451
Write a Python function to describe a place that holds special significance to you. The function should include the name of the place, its location, a brief description, sensory experiences that made it memorable, and any historical or cultural significance of the location. The function should return a dictionary conta...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import Dict def describe_special_place() -> Dict: """ Describes a place that holds special significance, including its name, location, description, sensory experiences, and historical or cultural significance. ...
python_sharegpt_23k
17,457
Write a Python function to categorize a given word as an adverb based on common suffixes and rules. The function should return a boolean value indicating whether the word is an adverb or not. The function should consider common suffixes like "ly" and other rules that might indicate a word is an adverb. The code should...
Here is the Python code to solve the given problem in the markdown block: ```python def is_adverb(word: str) -> bool: """ Determines if a given word is an adverb based on common suffixes and rules. Args: word (str): The word to be categorized. Returns: bool: True if the word is an adve...
python_sharegpt_23k
17,458
Write a Python function to convert a number from scientific notation to decimal notation. The function should take a string in the format "coefficienteexponent" (e.g., "12.5e0") as input and return the number in decimal notation as a float. The function should handle both positive and negative exponents. The code shou...
Here is the Python code to solve the given problem in the markdown block: ```python def scientific_to_decimal(num: str) -> float: """ Converts a number from scientific notation to decimal notation. Args: num (str): A string representing a number in scientific notation, e.g., "12.5e0". Returns:...
python_sharegpt_23k
17,460
Write a Python function to check if a given string contains any substring of length at least 3 that is a palindrome. The function should return `True` if such a substring exists, otherwise `False`. The code should start with: ```python def contains_palindrome_substring(s: str) -> bool: ```
Here is the Python code to solve the given problem in the markdown block: : ```python def is_palindrome(s: str) -> bool: """ Returns True if the given string is a palindrome, False otherwise. """ return s == s[::-1] def contains_palindrome_substring(s: str) -> bool: """ Checks if the given stri...
python_sharegpt_23k
17,474
Write a Python function to scramble the letters of each word in a given phrase, while keeping the words in their original order. The function should return the scrambled phrase. The code should start with: ```python from typing import List import random def scramble_phrase(phrase: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import random def scramble_phrase(phrase: str) -> str: """ Scrambles the letters of each word in the given phrase while keeping the words in their original order. Args: phrase (str): The inp...
python_sharegpt_23k
17,478
Write a Python function to calculate the time difference in seconds between the current date and time and the exact moment when Neil Armstrong first set foot on the Moon's surface, considering the time zone differences. The function should also return a list of fascinating yet less popular facts or events linked to the...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List import datetime def time_difference_to_moon_landing() -> (float, List[str]): """ Calculate the time difference in seconds between the current date and time and the exact moment when Neil Armstrong first ...
python_sharegpt_23k
17,482
Write a Python function that computes the sum of two numbers. The function should take two arguments, `x` and `y`, and an optional parameter `round_to` which specifies whether the sum of the two numbers should be rounded to the nearest integer or decimal places. The function should only return the sum of the two number...
Here is the Python code to solve the given problem in the markdown block: ```python def sum_two_numbers(x, y, round_to=None): """ Computes the sum of two numbers, x and y, with optional rounding. Args: x (int or float): The first number to be summed. y (int or float): The second number to b...
python_sharegpt_23k
17,483
Write a Python function to rearrange the words in a given text string in alphabetical order. The function should use the Python built-in function `sorted()` to achieve this. The function should start with: ```python def sort_words_alphabetically(text: str) -> str: ```
Here is the Python code to solve the given problem in the markdown block: ```python def sort_words_alphabetically(text: str) -> str: """ Rearranges the words in a given text string in alphabetical order. Args: text (str): The input text string containing words to be sorted. Returns: st...
python_sharegpt_23k
17,485
Write a Python function to calculate the expression `10 + 2n` for a given range of values of `n` and determine whether each result is even or odd. The function should return a list of tuples where each tuple contains the result and its corresponding "EVEN" or "ODD" designation. The code should start with: ```python fr...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List, Tuple def calculate_and_classify(start: int, end: int) -> List[Tuple[int, str]]: """ Calculate the expression 10 + 2n for each integer n in the range [start, end] and classify each result as "EVEN" or "...
python_sharegpt_23k
17,487
Write a Python function that takes two lists, `list_a` and `list_b`, as input. `list_a` consists of odd numbers ranging from 3 to 9, and `list_b` contains even numbers ranging from 1 to 10, both inclusive. The function should output the product of the sum of all elements in `list_a` and `list_b`, and the difference bet...
Here is the Python code to solve the given problem in the markdown block: ```python from typing import List def calculate_product_sum_diff(list_a: List[int], list_b: List[int]) -> int: """ Calculate the product of the sum of all elements in list_a and list_b, and the difference between the maximum and mini...