source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
python_sharegpt_23k | 18,610 | Write a Python function to find the alphabetically first string from a given list of strings using the selection sort algorithm. The function should return the string that comes first in alphabetical order.
The code should start with:
```python
from typing import List
def find_alphabetically_first_string(strings: Lis... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_alphabetically_first_string(strings: List[str]) -> str:
"""
Finds the alphabetically first string from a given list of strings using the selection sort algorithm.
Args:
strings (Lis... |
python_sharegpt_23k | 18,612 | Write a Python function to identify and generate the formula for an arithmetic sequence given a list of integers. The function should determine if the sequence is arithmetic, and if so, return the formula in the form "a + dn", where "a" is the first term and "d" is the common difference. If the sequence is not arithmet... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def arithmetic_sequence_formula(sequence: List[int]) -> str:
"""
Identifies and generates the formula for an arithmetic sequence given a list of integers.
Args:
sequence (List[int]): A list ... |
python_sharegpt_23k | 18,617 | Write a Python function to calculate the sum of all integers between two given integers, inclusive. The function should handle cases where the first integer is greater than the second integer by iterating through the range in the correct order. The function should also include a docstring explaining its purpose, parame... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_between_numbers(m: int, n: int) -> int:
"""
Calculate the sum of all integers between two given integers, inclusive.
Args:
m (int): The first integer.
n (int): The second integer.
Returns:
... |
python_sharegpt_23k | 18,623 | Write a Python function to generate a list of five positive physical traits randomly selected from a predefined list of options. The function should return the list of selected traits. The predefined list of traits includes:
- Bright eyes
- Thick hair
- Rosy cheeks
- Long legs
- Straight teeth
- Clear skin
- Broad shou... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_traits() -> List[str]:
"""
Generates a list of five positive physical traits randomly selected from a predefined list.
Returns:
List[str]: A list containing... |
python_sharegpt_23k | 18,624 | Write a Python function to generate a random code that consists of four characters: two uppercase letters followed by two numbers. The letters should represent the initials of a program name, the first number should represent the number of trees in an outdoor classroom, and the second number should represent the total ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import random
import string
def generate_outdoor_classroom_code() -> str:
"""
Generates a random code consisting of four characters: two uppercase letters followed by two numbers.
The letters repres... |
python_sharegpt_23k | 18,644 | Write a Python function to extract the original words from a sequence of transformed words that have been prefixed with "drove" and suffixed with a pattern "verb-noun". The function should return the original words in the correct sequence.
The code should start with:
```python
def extract_original_words(transformed_wo... | Here is the Python code to solve the given problem in the markdown block:
```python
def extract_original_words(transformed_words: str) -> str:
"""
Extracts the original words from a sequence of transformed words that have been prefixed with "drove" and suffixed with a pattern "verb-noun".
Args:
tra... |
python_sharegpt_23k | 18,645 | 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_preserve_order(ar... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def remove_duplicates_preserve_order(arr: List[int]) -> List[int]:
"""
Removes duplicate elements from the given list of integers while preserving the order of the remaining elements.
Args:
... |
python_sharegpt_23k | 18,647 | 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 | 18,656 | Write a Python function to validate IPv4 addresses that may contain wildcards and special characters. The function should accept IPv4 addresses in the format "192.168.*.2" or "10.0.%.5", where '*' and '%' are examples of wildcards and special characters. The function should return `True` if the address is valid and `Fa... | Here is the Python code to solve the given problem in the markdown block:
```python
def validate_IPv4_with_wildcards(s: str) -> bool:
"""
Validates an IPv4 address that may contain wildcards and special characters.
Args:
s (str): The IPv4 address to validate.
Returns:
bool: True if the... |
python_sharegpt_23k | 18,664 | Write a Python function that takes two arguments: an integer `x` and a list of integers `y`, and returns a list of integers that are the result of multiplying `x` with each element in `y`. Additionally, write a function to calculate the sum of the resulting list. The code should start with:
```python
from typing import... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def multiply_elements(x: int, y: List[int]) -> List[int]:
"""
Multiplies each element in the list `y` by the integer `x`.
Args:
x (int): The integer to multiply each element in the list by.
... |
python_sharegpt_23k | 18,666 | Write a Python function to find the second smallest number in a given list of integers. The function should be efficient and leverage the `heapq` module to achieve this. The code should start with:
```python
from typing import List
import heapq
def find_second_smallest(numbers: List[int]) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import heapq
def find_second_smallest(numbers: List[int]) -> int:
"""
Find the second smallest number in a given list of integers.
Args:
numbers (List[int]): The list of integers from which ... |
python_sharegpt_23k | 18,674 | Write a Python function to extract unique elements from a given list while preserving the order of their first appearance. The function should take a list of elements as input and return a list of unique elements in the order they first appear in the input list.
The code should start with:
```python
from typing import... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_unique_elements(elements: List) -> List:
"""
Extracts unique elements from a given list while preserving the order of their first appearance.
Args:
elements (List): The list from... |
python_sharegpt_23k | 18,681 | Write a Python function to classify a list of abstract concepts as positive, negative, or neutral based on predefined keywords. The function should take a list of concepts as input and return a list of tuples, where each tuple contains a concept and its corresponding category. If a concept does not match any predefined... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def classify_concepts(concepts: List[str]) -> List[Tuple[str, str]]:
"""
Classify a list of abstract concepts as positive, negative, or neutral based on predefined keywords.
Args:
con... |
python_sharegpt_23k | 18,684 | Write a Python function that replaces the word "astounding" in a given sentence with a randomly selected synonym from a predefined list of synonyms. Additionally, the function should return a table of these synonyms along with their definitions. The code should start with:
```python
from typing import List, Tuple
impor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def replace_astounding_with_synonym(sentence: str) -> Tuple[str, List[Tuple[str, str]]]:
"""
Replaces the word "astounding" in the given sentence with a randomly selected synonym and... |
python_sharegpt_23k | 18,686 | 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 previ... |
python_sharegpt_23k | 18,688 | Write a Python function to normalize a given string by converting all characters to lowercase and removing any special characters or punctuation marks, while preserving the order of the remaining characters. The function should return the normalized string.
The code should start with:
```python
import re
def normaliz... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def normalize_string(input_string: str) -> str:
"""
Normalizes the given string by converting all characters to lowercase and removing any special characters or punctuation marks, while preserving the order of the rem... |
python_sharegpt_23k | 18,690 | 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 integers.
... |
python_sharegpt_23k | 18,697 | Write a Python function to reverse a given string using only built-in Python functions. The function should return the reversed string. 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 given string using only built-in Python functions.
Args:
word (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Us... |
python_sharegpt_23k | 18,699 | Write a Python function to generate a random list of adjectives to describe different aspects of spring. The function should take an integer `n` as input, which represents the number of adjectives to generate. The function should return a list of `n` randomly selected adjectives from a predefined list of adjectives rel... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_spring_adjectives(n: int) -> List[str]:
"""
Generates a random list of adjectives to describe different aspects of spring.
Args:
n (int): The number of adjectives ... |
python_sharegpt_23k | 18,703 | Write a Python function to recommend a dish based on the given ingredients. The available dishes are stored in a dictionary where the key is the name of the dish and the value is the required ingredients with their respective quantities in a dictionary. The function should return the name of the dish that can be made w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict, Optional
def recommend_dish(available_dishes: Dict[str, Dict[str, int]], ingredients: Dict[str, int]) -> Optional[str]:
"""
Recommends a dish based on the given ingredients and returns the name of the d... |
python_sharegpt_23k | 18,705 | Write a Python function to sort a list of integers in descending order and remove any duplicates. The function should take a list of integers as input and return a new list with the integers sorted in descending order and duplicates removed. The code should start with:
```python
from typing import List
def sort_and_re... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_and_remove_duplicates(lst: List[int]) -> List[int]:
"""
Sorts a list of integers in descending order and removes any duplicates.
Args:
lst (List[int]): The list of integers to be pr... |
python_sharegpt_23k | 18,706 | 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 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:
"""
Finds 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 form... |
python_sharegpt_23k | 18,707 | 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 | 18,710 | Write a Python function to implement the selection sort algorithm to sort a given array of numbers in descending order. Additionally, provide a detailed analysis of the time complexity of the algorithm in Big-O notation, explaining the number of comparisons and swaps performed, considering the worst-case scenario where... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def selection_sort_descending(arr: List[int]) -> List[int]:
"""
Sorts the given array of numbers in descending order using the selection sort algorithm.
Args:
arr (List[int]): The array of n... |
python_sharegpt_23k | 18,716 | 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 | 18,718 | Write a Python function to remove all occurrences of a specific word or phrase from a given text, irrespective of its case sensitivity or presence of special characters. The function should return the modified text after removing the specified word or phrase.
The code should start with:
```python
import re
def remove... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def remove_word_from_text(text: str, word: str) -> str:
"""
Removes all occurrences of a specific word or phrase from a given text, irrespective of its case sensitivity or presence of special characters.
Args:
... |
python_sharegpt_23k | 18,720 | Write a Python function to sort a list of ice cream flavors by their prices in ascending order, while excluding flavors that contain certain dietary restrictions. The input list should contain tuples where each tuple consists of a string representing the ice cream flavor, a float representing its price, and a list of s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def sort_ice_cream_flavors(ice_creams: List[Tuple[str, float, List[str]]], exclude_dietary: List[str]) -> List[Tuple[str, float, List[str]]]:
"""
Sorts a list of ice cream flavors by their prices ... |
python_sharegpt_23k | 18,729 | Write a Python function to generate a 150-word detailed description of a room. The description should include information about the type of flooring, ceiling height, wall color, and any unique architectural features such as crown molding or decorative pillars. Consider the lighting sources in the room and how they affe... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_room_description() -> str:
"""
Generates a 150-word detailed description of a room.
The description includes information about the type of flooring, ceiling height, wall color,
architectural ... |
python_sharegpt_23k | 18,731 | Write a Python function to remove all occurrences of a specified word from a given string. The function should handle cases where the word might appear multiple times in the 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 | 18,740 | Write a Python function to increment all numeric values in a given sentence by a specified increment value using regular expressions. The function should take a sentence and an increment value as inputs and return the modified sentence.
The code should start with:
```python
import re
def increment_numbers_in_sentence... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def increment_numbers_in_sentence(sentence: str, increment: int) -> str:
"""
Increments all numeric values in a given sentence by a specified increment value.
Args:
sentence (str): The sentence containing... |
python_sharegpt_23k | 18,741 | 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 | 18,746 | 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 | 18,747 | Write a Python function to calculate the sum of all grades in a dictionary that contains information about students, including their names, ages, and grades. The dictionary is structured such that each student's name maps to another dictionary containing their age and grade. The function should iterate through the dict... | 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 students.
Args:
students (Dict[str, Dict[str, int]]): A dictionary where ea... |
python_sharegpt_23k | 18,762 | Write a Python function to perform binary search on a sorted array of integers to find the index of a target value. If the target value is not found, return -1. The function should use the binary search algorithm, which involves repeatedly dividing the search interval in half. 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 binary_search(array: List[int], target: int) -> int:
"""
Perform binary search on a sorted array to find the index of a target value.
Args:
array (List[int]): A sorted list of integers.
... |
python_sharegpt_23k | 18,767 | 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 | 18,775 | Write a Python function to sum the first five even elements of a given array and check if the sum is greater than 10 and less than 20. The array contains 10 elements, where the first 5 elements are even numbers and the next 5 elements are odd numbers. Additionally, count and print the number of even and odd elements se... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_and_count_elements(arr: List[int]) -> None:
"""
Sum the first five even elements of a given array and check if the sum is greater than 10 and less than 20.
Additionally, count and print the n... |
python_sharegpt_23k | 18,779 | Write a Python function to generate a sentence that includes the words 'mango', 'colossal', and 'section' in a specific order. The sentence should always start with 'A colossal mango', followed by 'section' in the middle, and end with 'was found in the section'. The code should start with:
```python
def generate_senten... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_sentence() -> str:
"""
Generates a sentence that includes the words 'mango', 'colossal', and 'section' in a specific order.
The sentence structure is: "A colossal mango section was found in the section."
R... |
python_sharegpt_23k | 18,789 | Write a Python function to find the three least common values in a given list that are within the range [7, 12]. The function should also return the frequency of occurrence for each of these values in the list. The results should be displayed in a table format with the values listed in ascending order and their frequen... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_least_common_values(lst: List[int]) -> List[Tuple[int, int]]:
"""
Finds the three least common values in the given list that are within the range [7, 12]
and returns their frequencies... |
python_sharegpt_23k | 18,801 | 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 | 18,802 | Write a Python function that takes two prime numbers as input and returns their product. Additionally, the function should print a table showing the first 10 multiples of the product. The function should include error handling to ensure that both inputs are indeed prime numbers. The code should start with:
```python
de... | Here is the Python code to solve the given problem in the markdown block:
```python
def prime_multiples(num1: int, num2: int) -> int:
"""
Multiplies two prime numbers and prints a table of the first 10 multiples of their product.
Args:
num1 (int): The first prime number.
num2 (int): The sec... |
python_sharegpt_23k | 18,804 | Write a Python function to identify all the prime factors of a given number using the trial division method. The function should handle edge cases such as negative numbers and non-integer inputs. If the input is a negative number, the function should return the prime factors of its absolute value. If the input is not a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def prime_factors(n: int) -> List[int]:
"""
Identify all the prime factors of a given number using the trial division method.
Args:
n (int): The number for which to find the prime factors.
... |
python_sharegpt_23k | 18,805 | 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
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 subject and a ta... |
python_sharegpt_23k | 18,807 | Write a Python function to find the closest landmark to a given target landmark from a list of landmarks. The closest landmark is defined as the landmark with the smallest distance (in miles) to the target landmark. The distances between landmarks are provided in a dictionary where the keys are the names of the landmar... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def closest_landmark(target_landmark: str, landmark_list: List[str], landmark_distances: Dict[str, int]) -> str:
"""
Find the closest landmark to a given target landmark from a list of landmarks.
... |
python_sharegpt_23k | 18,812 | Write a Python function to generate all possible chords of three notes from a given musical scale. The scale is represented as a list of notes. Each chord should be a combination of three unique notes from the scale. The function should return a list of lists, where each inner list represents a chord.
The code should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import itertools
def generate_chords(scale: List[str]) -> List[List[str]]:
"""
Generate all possible chords of three notes from a given musical scale.
Args:
scale (List[str]): A list of stri... |
python_sharegpt_23k | 18,817 | 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, int]]) -> List[Dict[str, int]]:
"""
Sorts a list of food items in descending order based on their calorie content.
Args:
food_list (... |
python_sharegpt_23k | 18,821 | 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 given number is prime.
Args:
num (int): The number to check for primality.
Returns:
bool: True if the number is prime, False other... |
python_sharegpt_23k | 18,838 | Write a Python function that takes two integers as input and returns their sum. Additionally, the function should print the sum using the `print` statement. The function should be named `sum_two_numbers` and should start with:
```python
def sum_two_numbers(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_two_numbers(num1: int, num2: int) -> int:
"""
Calculate the sum of two integers and print the result.
Args:
num1 (int): The first integer.
num2 (int): The second integer.
Returns:
int: T... |
python_sharegpt_23k | 18,839 | Write a Python function to calculate the Levenshtein distance between two given strings. The Levenshtein distance is defined as the minimum number of single-character edits (insertions, deletions, or substitutions) required to change one word into the other. The function should start with:
```python
def levenshtein_dis... | Here is the Python code to solve the given problem in the markdown block:
```python
def levenshtein_distance(s1: str, s2: str) -> int:
"""
Calculate the Levenshtein distance between two strings.
The Levenshtein distance is the minimum number of single-character edits
(insertions, deletions, or substitu... |
python_sharegpt_23k | 18,840 | Write a Python function to categorize a given dictionary of fruits based on their pH values into two groups: acidic and non-acidic. The threshold pH value for acidic fruits is 4.0. The function should return a tuple containing two lists: one for acidic fruits and one for non-acidic fruits.
The code should start with:
... | 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]) -> Tuple[List[str], List[str]]:
"""
Categorizes a dictionary of fruits based on their pH values into acidic and non-acidic groups.
Args:
... |
python_sharegpt_23k | 18,843 | Write a Python function to generate a random rap verse containing two specified words from a given list. The function should return a string that includes these two words in a rap verse format. The rap verse should be creatively constructed to fit the theme of the words provided. 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
import random
def generate_rap_verse(words: List[str]) -> str:
"""
Generates a random rap verse containing two specified words from a given list.
Args:
words (List[str]): A list of words to ... |
python_sharegpt_23k | 18,844 | 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 | 18,845 | Write a Python function that takes a list of dictionaries as input and returns a new list of dictionaries containing only the keys that appear in all dictionaries of the input list. If there are no common keys among the dictionaries, the function should return an empty list. The function should handle cases where the i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def common_keys_in_dicts(dicts: List[Dict[str, any]]) -> List[Dict[str, any]]:
"""
Returns a new list of dictionaries containing only the keys that appear in all dictionaries of the input list.
... |
python_sharegpt_23k | 18,847 | 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 | 18,849 | 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 | 18,855 | Write a Python function that converts all lowercase letters in a given string to uppercase using the ASCII table. The function should leave all other characters (including uppercase letters, digits, and special characters) unchanged. The code should start with:
```python
def convert_to_uppercase(s: str) -> str:
```
| 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 input string to uppercase using the ASCII table.
Args:
s (str): The input string containing lowercase and uppercase letters, digits,... |
python_sharegpt_23k | 18,857 | Write a Python function that takes an input list of integers and returns a dictionary where the keys are the original numbers and the values are their corresponding squares. Use the dictionary data type to store the results. The code should start with:
```python
from typing import List, Dict
def create_square_dict(inp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def create_square_dict(input_list: List[int]) -> Dict[int, int]:
"""
Creates a dictionary where the keys are the original numbers from the input list
and the values are their corresponding squa... |
python_sharegpt_23k | 18,858 | Write a Python function to filter a shopping list to include only organic and gluten-free items that are safe for a dinner party with vegetarian guests who have nut allergies. The function should take a list of items and four sets of items that meet specific criteria (organic, gluten-free, vegetarian, and nut-free) and... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Set
def filter_shopping_list(shopping_list: List[str], organic_items: Set[str], gluten_free_items: Set[str], vegetarian_items: Set[str], nut_free_items: Set[str]) -> List[str]:
"""
Filters a shopping li... |
python_sharegpt_23k | 18,865 | Write a Python function to classify a list of animals into mammals and nocturnal mammals. The function should return two lists: one containing the names of mammals and the other containing the names of nocturnal mammals. The animals to consider are Lion, Snake, and Dolphin.
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, Tuple
def classify_animals(animals: List[str]) -> Tuple[List[str], List[str]]:
"""
Classify a list of animals into mammals and nocturnal mammals.
Args:
animals (List[str]): A list of animal... |
python_sharegpt_23k | 18,869 | Write a Python function to evaluate the authenticity of a given sequence of parentheses, including different types of brackets such as square brackets, curly brackets, and angle brackets. The function should ensure that the brackets are balanced, properly nested, and not overlapping. The function should return `True` i... | Here is the Python code to solve the given problem in the markdown block:
```python
def is_valid_parentheses(s: str) -> bool:
"""
Evaluates the authenticity of a given sequence of parentheses, including different types of brackets.
Args:
s (str): The sequence of parentheses to evaluate.
Return... |
python_sharegpt_23k | 18,879 | 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 | 18,888 | Write a Python function to remove all alphabetic characters from a given alphanumeric string and return the resulting numeric string. The function should handle strings of varying lengths and ensure that only numeric characters are retained in the output.
The code should start with:
```python
def remove_alphabets(s: s... | Here is the Python code to solve the given problem in the markdown block:
```python
def remove_alphabets(s: str) -> str:
"""
Removes all alphabetic characters from the given alphanumeric string and returns the resulting numeric string.
Args:
s (str): The alphanumeric string from which alphabetic ch... |
python_sharegpt_23k | 18,893 | Write a Python function to find the maximum and minimum values for floats and strings in a list, and handle nested lists by returning a nested dictionary with the same keys. The function should return a dictionary with "max" and "min" keys for each data type (float and string) found in the list. If the list contains ne... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Union, Dict
def find_max_min(data: Union[List[Union[float, str, List]], float, str]) -> Dict[str, Dict[str, Union[float, str]]]:
"""
Find the maximum and minimum values for floats and strings in a list,... |
python_sharegpt_23k | 18,894 | 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 input list is empty by returning 0.0.
T... | 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 | 18,916 | Write a Python function to determine if a given list of words forms a circular chain of palindromes. A circular chain of palindromes is defined as a sequence where each word is a palindrome and the first letter of each word (except the first word) matches the last letter of the previous word, and the first letter of th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_circular_palindrome_chain(words: List[str]) -> bool:
"""
Determines if the given list of words forms a circular chain of palindromes.
Args:
words (List[str]): A list of words to check... |
python_sharegpt_23k | 18,923 | Write a Python function to initialize two integer variables `a` and `b` such that their sum is an odd number. Then, compute the product of these two variables, find the square root of the product, and round it to the nearest integer. Return the resulting value.
The code should start with:
```python
import math
def co... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def compute_final_value(a: int, b: int) -> int:
"""
Initialize two integers a and b such that their sum is odd, compute their product,
find the square root of the product, round it to the nearest integer, and re... |
python_sharegpt_23k | 18,924 | Write a Python function to generate a list of four distinct adjectives describing happiness. The function should ensure that each adjective is unique and not replicated. Use the `random` module to select adjectives from a predefined list. The code should start with:
```python
from typing import List
import random
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_distinct_happiness_adjectives() -> List[str]:
"""
Generates a list of four distinct adjectives describing happiness.
Returns:
List[str]: A list containing four uni... |
python_sharegpt_23k | 18,931 | Write a Python function to calculate the product of two integers using a recursive approach. The function should handle both positive and negative integers. The code should start with:
```python
def recursive_multiply(a: int, b: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def recursive_multiply(a: int, b: int) -> int:
"""
Calculate the product of two integers using a recursive approach.
Args:
a (int): The first integer.
b (int): The second integer.
Returns:
int: ... |
python_sharegpt_23k | 18,932 | 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 | 18,939 | Write a Python function to reverse the order of words in a given sentence. The function should handle sentences with varying lengths and should preserve the order of characters within each word. The code should start with:
```python
def reverse_words_order(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_words_order(sentence: str) -> str:
"""
Reverses the order of words in a given sentence.
Args:
sentence (str): The input sentence whose words need to be reversed.
Returns:
str: A new senten... |
python_sharegpt_23k | 18,942 | 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 coordinates for the points.
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 | 18,943 | Write a Python function to find the highest and lowest values for each attribute in a given dataset. The dataset is 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 values of each... | 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 | 18,946 | 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. The list should include at least 10 jokes involving various historical figures. The code should start with:
```python
from typing import List
de... | 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(jokes: List[str]) -> str:
"""
Generates a random historical figure joke from a given list of jokes.
Args:
jokes (List[str]): A list of strings wh... |
python_sharegpt_23k | 18,951 | Write a Python function to reverse the order of characters in a given string. The function should take a string as input and return the reversed string. The code should start with:
```python
def reverse_string(s: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(s: str) -> str:
"""
Reverses the order of characters in a given string.
Args:
s (str): The input string to be reversed.
Returns:
str: The reversed string.
"""
# Use string sli... |
python_sharegpt_23k | 18,954 | Write a Python function that randomly selects an idiom from a given list of idioms and returns a tuple containing the idiom and its meaning. The function should handle a list of idioms and their meanings provided as a dictionary. The code should start with:
```python
from typing import Dict, Tuple
import random
def ge... | 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.
Args:
idioms (Dict[s... |
python_sharegpt_23k | 18,955 | Write a Python function to find the longest palindrome in a given list of words. A palindrome is a word that reads the same backward as forward. The function should return the longest palindrome found in the list. If there are multiple palindromes with the same maximum length, return the first one encountered.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_longest_palindrome(words: List[str]) -> str:
"""
Finds the longest palindrome in a given list of words.
Args:
words (List[str]): A list of words to search for the longest palindrome... |
python_sharegpt_23k | 18,956 | 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 sunrise times are provided as a list of strings in the format `'YYYY-MM-DD HH:MM:SS'`. The function should return the complete sentence with the missing word filled in.
The ... | 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 | 18,959 | Write a Python function to compute the quotient and remainder of a given number divided by 5, and then identify the highest remainder among a range of numbers. The function should also return a list of tuples, where each tuple contains a number from the range, its quotient, and its remainder when divided by 5. The code... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def analyze_division_by_five(numbers: List[int]) -> Tuple[List[Tuple[int, int, int]], int]:
"""
Analyzes the division of a list of numbers by 5, computing the quotient and remainder for each numbe... |
python_sharegpt_23k | 18,960 | 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 | 18,967 | Write a Python function to find the top three most popular vegetables from a given list of vegetables and their respective popularity rankings. The input is a list of tuples, where each tuple contains the name of a vegetable and its popularity ranking. The function should return a list of the names of the top three mos... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def find_top_three_vegetables(vegetables: List[Tuple[str, int]]) -> List[str]:
"""
Finds the top three most popular vegetables from a given list of vegetables and their popularity rankings.
A... |
python_sharegpt_23k | 18,968 | 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 return the second smallest number. The code should start with:
```python
from typing import List
def find_second_smallest(numbers: List[int]) -> ... | 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 | 18,983 | Write a Python function to rewrite a given sentence while preserving its original meaning. The function should replace specific phrases in the sentence with semantically equivalent phrases. The code should start with:
```python
def rewrite_sentence(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def rewrite_sentence(sentence: str) -> str:
"""
Rewrites the given sentence by replacing specific phrases with semantically equivalent phrases.
Args:
sentence (str): The original sentence to be rewritten.
Retur... |
python_sharegpt_23k | 18,984 | 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 | 18,989 | Write a Python function to construct a meaningful sentence from a given list of words. The function should ensure that the sentence makes grammatical sense by selecting appropriate words for each part of the sentence. The sentence structure should be: "The [noun] of [noun] can be [adjective] [adverb] [verb]." The funct... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def construct_sentence(words: List[str]) -> str:
"""
Constructs a meaningful sentence from a given list of words.
The sentence structure is: "The [noun] of [noun] can be [adjective] [adverb] [verb].... |
python_sharegpt_23k | 18,991 | Write a Python function to count the number of occurrences of each unique word in a given sentence. The function should return the result as a dictionary where the keys are the unique words and the values are the number of occurrences. The sentence may contain punctuation and mixed case letters, so the function should ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import string
def count_word_occurrences(sentence: str) -> Dict[str, int]:
"""
Count the number of occurrences of each unique word in a given sentence.
Args:
sentence (str): The sentence fro... |
python_sharegpt_23k | 18,996 | Write a Python function to generate a random color in RGB format and provide a clue based on the dominant color component (red, green, or blue) to help solve a riddle. The riddle is: "I am vast and constantly shifting, my magnificence is limitless, I display serene nature yet fierce intensity, and I am teeming with lif... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_color_clue() -> tuple:
"""
Generates a random color in RGB format and provides a clue based on the dominant color component to help solve a riddle.
The riddle is: "I am vast and constantly shifti... |
python_sharegpt_23k | 19,008 | Write a Python function that takes a list of dictionaries and a key-value pair as input, and returns a new list of dictionaries that contain the specified key-value pair. The function should use dictionary comprehension to achieve this.
The code should start with:
```python
from typing import List, Dict
def get_dicti... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def get_dictionaries_with_key_value_pair(dict_list: List[Dict[str, any]], key: str, value: any) -> List[Dict[str, any]]:
"""
Returns a new list of dictionaries that contain the specified key-value ... |
python_sharegpt_23k | 19,013 | Write a Python function to remove specific words from a dataset of course reviews. The function should handle variations in grammar and word order within the sentences and should also handle cases where the targeted word is part of a larger word. The function should use regular expressions to ensure that the words are ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def remove_targeted_words(dataset: List[str], words_to_remove: List[str]) -> List[str]:
"""
Removes specific words from a dataset of course reviews.
Args:
dataset (List[str]): A li... |
python_sharegpt_23k | 19,021 | 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 while maintaining its functionality. The code should start with:
```python
from typing import List
def check_data(data: List[str])... | 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 | 19,027 | Write a Python function to reverse a given list of integers. The function should return a new list that is the reverse of the input list, without modifying the original list. The code should start with:
```python
from typing import List
def reverse_list(input_list: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def reverse_list(input_list: List[int]) -> List[int]:
"""
Returns a new list that is the reverse of the input list without modifying the original list.
Args:
input_list (List[int]): The li... |
python_sharegpt_23k | 19,035 | Write a Python function to find the three most frequently occurring words in a given sentence, ignoring punctuation and case sensitivity. The function should return a list of these three words in descending order of their frequency. If there are fewer than three unique words, the function should return as many as are a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import string
def most_frequent_words(sentence: str) -> List[str]:
"""
Find the three most frequently occurring words in a given sentence, ignoring punctuation and case sensitivity.
Args:
se... |
python_sharegpt_23k | 19,040 | Write a Python function to generate a random license plate number in the format of "XX-###-XX", where "X" is a random uppercase letter and "#" is a random digit. The function should return the generated license plate number as a string.
The code should start with:
```python
import random
def generate_license_plate() ... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_license_plate() -> str:
"""
Generates a random license plate number in the format "XX-###-XX",
where "X" is a random uppercase letter and "#" is a random digit.
Returns:
str: A string... |
python_sharegpt_23k | 19,051 | Write a Python function to calculate the age of a person when they completed a specific 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) -> in... | 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 when they completed a specific work.
Args:
birth_year (int): The birth year of the person.
com... |
python_sharegpt_23k | 19,060 | Write a Python function to calculate the average marks of a class given a list of marks. The function should handle cases where the list might be empty and return `None` in such scenarios. The code should start with:
```python
from typing import List, Optional
def calculate_average_marks(marks: List[int]) -> Optional[... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
def calculate_average_marks(marks: List[int]) -> Optional[float]:
"""
Calculate the average marks of a class given a list of marks.
Args:
marks (List[int]): A list of integers repr... |
python_sharegpt_23k | 19,063 | Write a Python function that takes an array of integers and returns the sum of all the prime numbers within the array, the largest prime number, the smallest prime number, and the total count of prime numbers. The input array should be sorted in descending order before processing. The function should handle arrays of a... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def prime_numbers_summary(arr: List[int]) -> Tuple[int, int, int, int]:
"""
Returns the sum, largest, smallest, and count of prime numbers in the given array.
Args:
arr (List[int]): T... |
python_sharegpt_23k | 19,064 | 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 | 19,066 | Write a Python function to generate a string that emphasizes a given word or phrase using the "epizeuxis" rhetorical device, which involves repeating the word or phrase in quick succession. The function should allow customization of the number of repetitions and the punctuation used for emphasis. The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
def emphasize_with_epizeuxis(phrase: str, repetitions: int = 3, punctuation: str = "!") -> str:
"""
Generates a string that emphasizes a given word or phrase using the "epizeuxis" rhetorical device.
Args:
phrase (st... |
python_sharegpt_23k | 19,067 | Write a Python function to calculate the sum of multiple numbers efficiently, especially for large datasets. The function should accept a list of integers and return the sum. Additionally, the function should be optimized to handle large datasets efficiently. 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
def efficient_sum(numbers: List[int]) -> int:
"""
Calculate the sum of multiple numbers efficiently, especially for large datasets.
Args:
numbers (List[int]): A list of integers to be summed... |
python_sharegpt_23k | 19,069 | Write a Python function to calculate the sales tax and deduct it from a given subtotal. The function should take the subtotal and the tax rate as inputs and return the total amount after deducting the sales tax. The code should start with:
```python
def calculate_total_after_tax(subtotal: float, tax_rate: float) -> flo... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_total_after_tax(subtotal: float, tax_rate: float) -> float:
"""
Calculate the total amount after deducting the sales tax from the given subtotal.
Args:
subtotal (float): The initial amount before tax.
... |
python_sharegpt_23k | 19,080 | Write a Python function to calculate the average weight of all animals in a zoo for the month of August, ensuring data validation and access control measures. The function should handle a list of dictionaries, each representing an animal with keys `name`, `weight_august`, and `species`. The function should filter out n... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def calculate_average_weight(animals_list: List[Dict[str, any]], authorized_personnel: str) -> float:
"""
Calculate the average weight of all animals in the zoo for the month of August, ensuring da... |
python_sharegpt_23k | 19,088 | Write a Python function to classify a list of data points based on the given classification rule and return a dictionary containing the count of data points classified as "A" and "B". Each data point is a tuple consisting of two values: a numerical value `x` and a binary value `y`. The classification rule is as follows... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple, Dict
def classify_data_points(data_points: List[Tuple[int, int]]) -> Dict[str, int]:
"""
Classify a list of data points based on the given rule and return a dictionary
containing the count of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.