source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
python_sharegpt_23k | 21,868 | 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, any]:
"""
Generates a classification puzzle for nocturnal mammals living in underground burrows in the African savanna... |
python_sharegpt_23k | 21,870 | Write a Python function to convert a number from a given base to its decimal representation, and then to its equivalent binary and hexadecimal representations. The function should also display these conversions in a table format. Additionally, the function should handle potential errors or edge cases, such as invalid b... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_base_to_decimal_and_display(number_str: str, base: int) -> None:
"""
Converts a number from a given base to its decimal representation, and then to its equivalent binary and hexadecimal representations.
Displays ... |
python_sharegpt_23k | 21,872 | Write a Python function to extract all numerical values from a given string while removing all HTML elements. The function should return a list of these numerical values. The code should start with:
```python
from typing import List
import re
def extract_numbers_from_string(input_string: 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_numbers_from_string(input_string: str) -> List[str]:
"""
Extracts all numerical values from a given string while removing all HTML elements.
Args:
input_string (str): T... |
python_sharegpt_23k | 21,879 | Write a Python function to calculate the sum of the first `n` positive integers and another function to calculate the sum of the first `n` even positive integers. The functions should be efficient and avoid unnecessary computations.
The code should start with:
```python
def sum_of_first_n_integers(n: int) -> int:
def ... | Here is the Python code to solve the given problem in the markdown block:
```python
def sum_of_first_n_integers(n: int) -> int:
"""
Calculate the sum of the first n positive integers.
Args:
n (int): The number of positive integers to sum.
Returns:
int: The sum of the first n positive i... |
python_sharegpt_23k | 21,886 | 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 | 21,887 | Write a Python function to randomly generate a list of five rare items, one from each category, for a virtual reality game. The categories and their corresponding items are predefined. The function should ensure that each item is unique and belongs to a different category. The code should start with:
```python
from typ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
import random
def generate_rare_items(categories: Dict[str, List[str]]) -> List[str]:
"""
Randomly generates a list of five unique rare items, one from each category.
Args:
categories ... |
python_sharegpt_23k | 21,889 | Write a Python function to convert a traditional Italian tiramisu recipe into a vegan version by modifying the ingredient list. The function should replace non-vegan ingredients with their vegan alternatives while maintaining the classic taste of the dish. 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
def convert_to_vegan_tiramisu(ingredients: List[str]) -> List[str]:
"""
Converts a traditional Italian tiramisu recipe into a vegan version by replacing non-vegan ingredients with vegan alternatives.
... |
python_sharegpt_23k | 21,896 | 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 use regular expressions to ensure robustness.
The code should start with:
```python
import re
def remove_word_from_text(text: st... | 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 | 21,901 | Write a Python function to check if a given string contains any substring that is a palindrome of length greater than 1. 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.
Args:
s (str): The string to check.
Returns:
bool: True if the string is a palindrome, F... |
python_sharegpt_23k | 21,905 | Write a Python function to calculate the age of a person when they completed a significant work given their birth year and the year of completion. 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) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_age_at_completion(birth_year: int, completion_year: int) -> int:
"""
Calculate the age of a person at the time of completing a significant work.
Args:
birth_year (int): The birth year of the person.
... |
python_sharegpt_23k | 21,907 | Create a Python function that generates a dictionary with five key-value pairs, where the values are all prime numbers. The keys must follow specific criteria:
1. The first key must be a palindrome and represent a type of animal often associated with intelligence.
2. The second key must be a combination of the chemical... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_prime_dictionary() -> dict:
"""
Generates a dictionary with five key-value pairs where the values are prime numbers.
The keys follow specific criteria:
1. The first key is a palindrome representing an intell... |
python_sharegpt_23k | 21,910 | Write a Python function to generate a username that matches the identity of a British hipster using regular expressions. The username must start with "hip" and end with "ster", and it must contain at least one of the following words: "tea", "vinyl", "beard", "tweed", "glasses", or "vegan". The function should return th... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def generate_hipster_username(text: str) -> str:
"""
Generates a username that matches the identity of a British hipster using regular expressions.
The username must start with "hip", end with "ster", and contain... |
python_sharegpt_23k | 21,914 | Write a Python function to calculate the sum of the squares of a list of numbers. The function should be efficient and capable of handling lists of varying lengths, complexities, and data types. Additionally, consider the potential impacts of utilizing different programming languages, libraries, and frameworks on the o... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sum_of_squares(lst: List[int]) -> int:
"""
Calculate the sum of the squares of a list of integers.
Args:
lst (List[int]): A list of integers for which the sum of squares is to be calcula... |
python_sharegpt_23k | 21,916 | Write a Python function to evaluate the numerical results of dividing a series of numbers by 5, calculate both the quotient and the remainder for each division, and then determine the maximum value among these results. The function should return a dictionary where the keys are the numbers from the series, and the value... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict, Tuple
def evaluate_division_results(numbers: List[int]) -> Dict[int, Tuple[float, int, float]]:
"""
Evaluates the numerical results of dividing a series of numbers by 5.
For each number in th... |
python_sharegpt_23k | 21,917 | Write a Python function to convert a given temperature in Celsius to Fahrenheit using the formula `(Celsius * 9/5) + 32`. The function should be able to handle both positive and negative temperatures. Additionally, create a function that generates a table of Fahrenheit equivalents for Celsius temperatures ranging from ... | Here is the Python code to solve the given problem in the markdown block:
```python
def celsius_to_fahrenheit(celsius: float) -> float:
"""
Converts a given temperature in Celsius to Fahrenheit.
Args:
celsius (float): The temperature in Celsius to be converted.
Returns:
float: The temp... |
python_sharegpt_23k | 21,918 | 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 parameters representing the lengths of the legs and return the length of the hypotenuse. The code should start with:
```python
import math
def calculate_... | 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 | 21,921 | Write a Python function to categorize a given word as an adverb based on common suffixes used to identify adverbs. The function should check if the word ends with "ly", "ily", "ward", or "wise" and return a boolean indicating whether the word is an adverb. Additionally, provide a brief explanation of why these suffixes... | 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 used to identify adverbs.
Args:
word (str): The word to be categorized.
Returns:
bool: True if the ... |
python_sharegpt_23k | 21,923 | Write a Python function to generate a random number between 1 and 100 that is not divisible by 5. The function should ensure that the generated number meets this criterion.
The code should start with:
```python
import random
def generate_random_number() -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_random_number() -> int:
"""
Generates a random number between 1 and 100 that is not divisible by 5.
Returns:
int: A random number between 1 and 100 that is not divisible by 5.
"""
... |
python_sharegpt_23k | 21,924 | Write a Python function to generate a limerick using a randomly selected word from a list of words that rhyme with "orange". The function should return the limerick as a string. The limerick template should be flexible enough to accommodate any word from the list.
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
import random
def generate_limerick(rhyming_words: List[str]) -> str:
"""
Generates a limerick using a randomly selected word from a list of words that rhyme with "orange".
Args:
rhyming_wor... |
python_sharegpt_23k | 21,931 | Write a Python function to generate a haiku verse that includes a noun, adjective, and verb from specific categories. The function should ensure that the generated verse adheres to the structure of a haiku, which typically consists of three lines with syllable counts of 5, 7, and 5, respectively. The categories and cor... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def generate_haiku(nouns: List[str], adjectives: List[str], verbs: List[str]) -> Tuple[str, str, str]:
"""
Generates a haiku verse using the provided lists of nouns, adjectives, and ... |
python_sharegpt_23k | 21,933 | Write a Python function to extract the essential words "celebrate", "victory", "parade", "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 List
im... | 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", "tomorrow" from a given sentence.
Args:
sentence (str): ... |
python_sharegpt_23k | 21,936 | Write a Python function to determine whether a given number is even or odd. The function should return a string indicating "Even" or "Odd".
The code should start with:
```python
def is_even_or_odd(number: int) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_even_or_odd(number: int) -> str:
"""
Determine whether the given number is even or odd.
Args:
number (int): The number to be checked.
Returns:
str: A string indicating "Even" if the number is eve... |
python_sharegpt_23k | 21,938 | Write a Python function to reverse the words in a given string while maintaining the order of the words. For example, if the input string is "Hello world", the output should be "world Hello". The function should handle strings with multiple spaces between words and leading/trailing spaces.
The code should start with:
... | Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_string(s: str) -> str:
"""
Reverses the words in a given string while maintaining the order of the words.
Args:
s (str): The input string containing words to be reversed.
Returns:
s... |
python_sharegpt_23k | 21,941 | Write a Python function to extract the original words from a sequence of transformed words, where each word has a common prefix and a unique suffix. The prefix is always "drove", and the suffix follows the pattern "verb-noun". The function should return the original words in the correct sequence.
The code should start... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_original_words(transformed_words: List[str]) -> List[str]:
"""
Extracts the original words from a list of transformed words.
Each transformed word has a common prefix "drove" and a uniqu... |
python_sharegpt_23k | 21,942 | Write a Python function to enhance a given sentence by wrapping a specific word with an HTML tag that includes a descriptive class. The function should take three parameters: the sentence as a string, the word to be tagged as a string, and the class name as a string. The function should return the modified sentence wit... | Here is the Python code to solve the given problem in the markdown block:
```python
def enhance_sentence_with_tag(sentence: str, word: str, class_name: str) -> str:
"""
Enhances a given sentence by wrapping a specific word with an HTML span tag that includes a descriptive class.
Args:
sentence (str... |
python_sharegpt_23k | 21,955 | Write a Python function to calculate the total distance traveled by birds over a given number of days. The function should take a list of integers representing the distances traveled each day and return the total distance. The code should start with:
```python
from typing import List
def calculate_total_distance(dista... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_total_distance(distances: List[int]) -> int:
"""
Calculate the total distance traveled by birds over a given number of days.
Args:
distances (List[int]): A list of integers rep... |
python_sharegpt_23k | 21,962 | Write a Python function that generates a random color in RGB format and uses it to provide a clue to the answer of 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 life. What am I?" The function should return a... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_riddle_clue() -> str:
"""
Generates a random color in RGB format and uses it to provide a clue to the answer of a riddle.
The riddle is: "I am vast and constantly shifting, my magnificence is... |
python_sharegpt_23k | 21,966 | 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 | 21,973 | Write a Python function to convert a given weight between kilograms and pounds, and another function to convert the weight of an object on Earth to its weight on the moon. The functions should be able to handle conversions in both directions (kilograms to pounds and pounds to kilograms) and provide the weight on the mo... | Here is the Python code to solve the given problem in the markdown block:
```python
def convert_weight(weight: float, from_unit: str, to_unit: str) -> float:
"""
Converts a given weight between kilograms and pounds.
Args:
weight (float): The weight to be converted.
from_unit (str): The unit... |
python_sharegpt_23k | 21,979 | 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 include a brief comment about an unusual event or lesser-known aspect of th... | Here is the Python code to solve the given problem in the markdown block:
```python
import datetime
def time_difference_to_moon_landing() -> float:
"""
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.
... |
python_sharegpt_23k | 21,984 | Write a Python function to extract all bigrams (consecutive pairs of words) from a given text. The function should return a list of tuples where each tuple contains a pair of words. The code should start with:
```python
from typing import List, Tuple
def extract_bigrams(text: str) -> List[Tuple[str, str]]:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def extract_bigrams(text: str) -> List[Tuple[str, str]]:
"""
Extracts all bigrams (consecutive pairs of words) from the given text.
Args:
text (str): The input text from which to extr... |
python_sharegpt_23k | 21,986 | Write a Python function to generate a vivid description of a high temperature using figurative language. The function should randomly select a comparison and a personification from predefined lists and combine them into a single descriptive sentence. The function should return the generated description as a string.
Th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def describe_high_temperature() -> str:
"""
Generates a vivid description of a high temperature using figurative language.
The function randomly selects a comparison and a personificat... |
python_sharegpt_23k | 21,987 | 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_dictio... | 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 | 21,988 | Write a Python function to convert a temperature from Fahrenheit to Celsius. The function should take a single argument representing the temperature in Fahrenheit and return the temperature in Celsius. The code should start with:
```python
def fahrenheit_to_celsius(fahrenheit: float) -> float:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def fahrenheit_to_celsius(fahrenheit: float) -> float:
"""
Convert a temperature from Fahrenheit to Celsius.
Args:
fahrenheit (float): The temperature in Fahrenheit.
Returns:
float: The temperature in C... |
python_sharegpt_23k | 21,992 | Write a Python function to generate a random sequence of 10 characters according to the following rules:
1. The first character is always an uppercase letter.
2. The next three characters are digits between 0 and 9.
3. The next four characters are lowercase letters.
4. The last two characters are either the special cha... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
import string
def generate_random_sequence() -> str:
"""
Generates a random sequence of 10 characters according to the following rules:
1. The first character is always an uppercase letter.
2. The next thr... |
python_sharegpt_23k | 21,993 | Write a Python function to extract the unique elements from a given list of integers. The function should return a list containing only the unique elements in the order they first appear in the input list.
The code should start with:
```python
from typing import List
def extract_unique_elements(input_list: List[int])... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def extract_unique_elements(input_list: List[int]) -> List[int]:
"""
Extracts the unique elements from a given list of integers while maintaining the order of their first appearance.
Args:
i... |
python_sharegpt_23k | 21,994 | Write a Python function to generate all possible chords of a given scale, where each chord consists of three notes. The scale is represented as a list of notes. The function should return a list of lists, where each inner list contains three notes representing a chord.
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 itertools
def generate_chords(scale: List[str]) -> List[List[str]]:
"""
Generate all possible chords of a given scale, where each chord consists of three notes.
Args:
scale (List[str]... |
python_sharegpt_23k | 21,997 | 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 | 21,998 | Write a Python function to filter and list out the specialized kitchen equipment required for molecular gastronomy dishes based on a given list of kitchen equipment. The function should return a list of equipment that is specifically related to molecular gastronomy. The code should start with:
```python
from typing imp... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def filter_molecular_gastronomy_equipment(equipment_list: List[str]) -> List[str]:
"""
Filters and returns a list of kitchen equipment that is specifically used in molecular gastronomy.
Args:
... |
python_sharegpt_23k | 22,003 | 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 function should be case-insensitive a... | 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.
This function is case-insensitive and ignore... |
python_sharegpt_23k | 22,005 | Write a Python function to find the most recent date from a list of dates in the format "YYYY-MM-DD". The function should handle any valid date strings in the specified format and return the most recent date.
The code should start with:
```python
from typing import List
def get_most_recent_date(dates: List[str]) -> s... | 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 | 22,008 | Write a Python function to generate a JavaScript-based cognitive assessment item. The assessment should present the test-taker with three options and challenge them to select the correct one. The function should randomize the wording and formatting of the options to make the assessment more challenging for the test-tak... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def generate_assessment_item(question: str, options: List[Tuple[str, List[str]]]) -> str:
"""
Generates a JavaScript-based cognitive assessment item.
Args:
question (str... |
python_sharegpt_23k | 22,023 | Write a Python function to generate a formal invitation for a networking event using Markdown syntax. The function should take event details as input parameters and return a formatted Markdown string. The event details include the event name, date and time, location, purpose, and RSVP instructions. The function should ... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_invitation(event_name: str, date_and_time: str, location: str, purpose: str, rsvp_email: str) -> str:
"""
Generates a formal invitation for a networking event using Markdown syntax.
Args:
event_name (st... |
python_sharegpt_23k | 22,025 | Write a Python function to generate a random sci-fi protagonist's character profile. The profile should include the following attributes: Name (string), Age (integer between 25 and 50), Gender (either "male" or "female"), Species (string), Occupation (string), Strength (integer between 1 and 8), Intelligence (integer b... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Dict
import random
def generate_character_profile() -> Dict[str, str]:
"""
Generates a random sci-fi protagonist's character profile.
Returns:
Dict[str, str]: A dictionary containing the characte... |
python_sharegpt_23k | 22,038 | Write a Python function to generate a random zodiac sign belonging to the fire element. The function should return the name of the zodiac sign as a string. The code should start with:
```python
from typing import List
import random
def get_random_fire_sign() -> 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_fire_sign() -> str:
"""
Generates a random zodiac sign belonging to the fire element.
Returns:
str: The name of a randomly selected fire element zodiac sign.
... |
python_sharegpt_23k | 22,040 | 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 l... |
python_sharegpt_23k | 22,043 | Write a Python function to generate a dictionary that shows the length of each word in a given sentence. The function should take a sentence as input and return a dictionary where the keys are the words from the sentence and the values are the lengths of those words.
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 Dict
def word_lengths_in_sentence(sentence: str) -> Dict[str, int]:
"""
Generates a dictionary that shows the length of each word in the given sentence.
Args:
sentence (str): The sentence from wh... |
python_sharegpt_23k | 22,044 | 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 | 22,048 | 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 | 22,050 | Write a Python function to perform non-deterministic decision-making on a given dataset. The function should randomly select an item from the dataset, shuffle the dataset, and generate a random number within a specified range. The function should return a tuple containing the randomly selected item, the shuffled datase... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def non_deterministic_decision_making(dataset: List[int], min_range: int, max_range: int) -> Tuple[int, List[int], int]:
"""
Perform non-deterministic decision-making on a given data... |
python_sharegpt_23k | 22,052 | Write a Python function to generate a haiku with a specific theme or subject. The haiku should consist of three lines with syllable counts of 5, 7, and 5 respectively. The function should take a theme as input and return the haiku as a string. The code should start with:
```python
from typing import List
import random
... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_haiku(theme: str) -> str:
"""
Generates a haiku with a specific theme. The haiku consists of three lines with syllable counts of 5, 7, and 5 respectively.
Args:
th... |
python_sharegpt_23k | 22,056 | Write a Python function to find the longest river in Africa from a given dataset of rivers and their lengths. The dataset is a dictionary where the keys are river names and the values are their lengths in kilometers. The function should return the name of the longest river.
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 Dict
def find_longest_river(rivers: Dict[str, int]) -> str:
"""
Finds the longest river in Africa from a given dataset of rivers and their lengths.
Args:
rivers (Dict[str, int]): A dictionary whe... |
python_sharegpt_23k | 22,057 | Write a Python function to generate a random numerical sequence of eight digits where each digit follows a Gaussian distribution with a specified mean and standard deviation. The function should ensure that each digit in the sequence is an integer between 0 and 9.
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
import numpy as np
def generate_gaussian_sequence(mean: float, std_dev: float) -> str:
"""
Generates a random numerical sequence of eight digits where each digit follows a Gaussian distribution.
Arg... |
python_sharegpt_23k | 22,058 | 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 | 22,065 | Write a Python function to generate a random numerical sequence of exactly eight digits, where each digit follows a Gaussian distribution with a specified mean and standard deviation. The function should ensure that the generated digits are within the valid range of 0 to 9.
The code should start with:
```python
from t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
import math
def generate_gaussian_sequence(mean: float, stddev: float) -> List[int]:
"""
Generates a random numerical sequence of exactly eight digits, where each digit follows a Gaussian d... |
python_sharegpt_23k | 22,068 | Write a Python function to reverse the order of words in a given sentence. The function should handle sentences with varying lengths, including empty sentences. The code should start with:
```python
def reverse_words_in_sentence(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_words_in_sentence(sentence: str) -> str:
"""
Reverses the order of words in a given sentence.
Args:
sentence (str): The input sentence to reverse the words of.
Returns:
str: The sentence wit... |
python_sharegpt_23k | 22,076 | 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 | 22,079 | Write a Python function to find the missing word in a sentence using a list of sunrise times. The function should take a list of sunrise times in the format `'YYYY-MM-DD HH:MM:SS'` and a target date in the format `'YYYY-MM-DD'`. The function should return the missing word in the sentence "The sun rose _____ the horizon... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Optional
import datetime
def find_missing_word(sunrise_times: List[str], target_date: str) -> Optional[str]:
"""
Finds the missing word in the sentence "The sun rose _____ the horizon on [target date]."... |
python_sharegpt_23k | 22,082 | Write a Python function to convert a fraction into its decimal equivalent. The function should take two positive integer inputs, the numerator and the denominator, and return the decimal equivalent as a float. The function should be able to handle any positive integer values for the numerator and denominator. The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def fraction_to_decimal(numerator: int, denominator: int) -> float:
"""
Converts a fraction into its decimal equivalent.
Args:
numerator (int): The numerator of the fraction. Must be a positive integer.
deno... |
python_sharegpt_23k | 22,085 | Update the given Python 2 code snippet to Python 3 syntax, specifically modifying the print statement to use parentheses and replacing the string with a variable that contains the greeting "Hello World!". Additionally, write a function that takes a greeting message as input and prints it. The function should be designe... | Here is the Python code to solve the given problem in the markdown block:
```python
#!/usr/bin/python3
# Greeting python program
def print_greeting(message: str) -> None:
"""
Prints the given greeting message.
Args:
message (str): The greeting message to be printed.
Returns:
None
... |
python_sharegpt_23k | 22,088 | Write a Python function to correct common typos in a given text using regular expressions. The function should identify and correct specific typos such as missing letters, transposed letters, and extra letters. The function should return the corrected text.
The code should start with:
```python
import re
def correct_... | Here is the Python code to solve the given problem in the markdown block:
```python
import re
def correct_typos(text: str) -> str:
"""
Corrects common typos in a given text using regular expressions.
Args:
text (str): The input text containing typos.
Returns:
str: The corrected text w... |
python_sharegpt_23k | 22,091 | Write a Python function to measure the time it takes to print a string of varying lengths and to explore different formatting options such as font size and color. The function should also discuss potential memory constraints and optimization techniques for the string printing process. The code should start with:
```pyt... | Here is the Python code to solve the given problem in the markdown block:
```python
import time
def measure_print_time(string: str) -> float:
"""
Measures the time it takes to print a given string and explores different formatting options.
Args:
string (str): The string to be printed.
Returns... |
python_sharegpt_23k | 22,098 | Write a Python function to determine if a given number is divisible by 6 using the modulo operator. The function should return a boolean value indicating whether the number is divisible by 6. The code should start with:
```python
def is_divisible_by_6(number: int) -> bool:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def is_divisible_by_6(number: int) -> bool:
"""
Determines if a given number is divisible by 6.
Args:
number (int): The number to check for divisibility by 6.
Returns:
bool: True if the number is divisi... |
python_sharegpt_23k | 22,099 | Write a Python function to invert the order of words in a given sentence. The function should take a string as input and return a new string with the words in reverse order. The code should start with:
```python
def invert_sentence_order(sentence: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def invert_sentence_order(sentence: str) -> str:
"""
Inverts the order of words in a given sentence.
Args:
sentence (str): The input sentence whose words are to be reversed.
Returns:
str: A new sentence... |
python_sharegpt_23k | 22,106 | Write a Python function to generate a random code that consists of four characters: two uppercase letters followed by two numbers. The letters represent the initials of a program name, the first number represents the number of trees in an outdoor classroom, and the second number represents the total number of students ... | Here is the Python code to solve the given problem in the markdown block:
```python
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 represent the initials of a pro... |
python_sharegpt_23k | 22,107 | Write a Python function to count the number of unique characters that appear in two given strings without using intersection or loops for character comparison. The function must have a time complexity of O(n), where n is the length of the longer string, and should utilize Python's built-in data structures. The code sho... | Here is the Python code to solve the given problem in the markdown block:
```python
def count_unique_chars(str1: str, str2: str) -> int:
"""
Counts the number of unique characters that appear in two given strings.
Args:
str1 (str): The first string.
str2 (str): The second string.
Retur... |
python_sharegpt_23k | 22,108 | Write a Python function to generate a random Shakespearean insult along with its meaning from a predefined list of insults and their meanings. The function should randomly select an insult from the list and return both the insult and its meaning as a tuple.
The code should start with:
```python
from typing import Tupl... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import random
def generate_random_insult() -> Tuple[str, str]:
"""
Generates a random Shakespearean insult along with its meaning.
Returns:
Tuple[str, str]: A tuple containing the randomly ... |
python_sharegpt_23k | 22,110 | 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(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 given string using only built-in Python functions.
Args:
s (str): The string to be reversed.
Returns:
str: The reversed string.
"""
# Use sl... |
python_sharegpt_23k | 22,111 | Write a Python function to shift all the letters in a given string two characters ahead in the alphabet. For example, if the input string is "apple", the output should be "crrng". The function should handle both uppercase and lowercase letters, and any non-alphabetic characters should remain unchanged.
The code should... | Here is the Python code to solve the given problem in the markdown block:
```python
def shift_letters_by_two(word: str) -> str:
"""
Shifts all the letters in the given string two characters ahead in the alphabet.
Args:
word (str): The input string to be shifted.
Returns:
str: The new s... |
python_sharegpt_23k | 22,120 | Write a Python function to sort a list of ice cream flavors by their prices while excluding flavors with specified dietary restrictions. The input list contains tuples where each tuple consists of a string representing the ice cream flavor, a float representing its price, and a list of strings representing its dietary ... | 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 | 22,121 | 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.
Args:
input_string (str)... |
python_sharegpt_23k | 22,125 | Write a Python function to convert a given string to camelCase. The input string will be in snake_case format, where words are separated by underscores. The function should return the string converted to camelCase, where the first word is in lowercase and each subsequent word starts with an uppercase letter.
The code ... | Here is the Python code to solve the given problem in the markdown block:
```python
def to_camel_case(snake_case_string: str) -> str:
"""
Converts a given snake_case string to camelCase.
Args:
snake_case_string (str): The input string in snake_case format.
Returns:
str: The converted s... |
python_sharegpt_23k | 22,127 | Write a Python function to generate a personalized letter of recommendation for a candidate, 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 fo... | 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 | 22,129 | Write a Python function to perform integer division and calculate the remainder of the division between two integers. The function should return both the quotient and the remainder. Additionally, provide a detailed explanation of the difference between floor division and integer division in Python, and give an example ... | Here is the Python code to solve the given problem in the markdown block:
```python
def integer_division_with_remainder(num1: int, num2: int) -> tuple:
"""
Perform integer division and calculate the remainder of the division between two integers.
Args:
num1 (int): The dividend.
num2 (int): ... |
python_sharegpt_23k | 22,133 | 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 the count of each classification.
A... |
python_sharegpt_23k | 22,135 | Write a Python function that applies a given mathematical formula to each element of a list of integers using the `map()` function. The mathematical formula should be defined as a separate function. The function should return the transformed list.
The code should start with:
```python
from typing import List
def appl... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def complex_formula(num: int) -> int:
"""
A complex mathematical formula applied to each element in the list.
Args:
num (int): The integer to which the formula is applied.
Returns:
... |
python_sharegpt_23k | 22,137 | Write a Python function to perform integer division and return both the quotient and the remainder. The function should handle both positive and negative dividends and divisors. The code should start with:
```python
def integer_division(dividend: int, divisor: int) -> tuple:
```
| 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 | 22,140 | 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 | 22,145 | Write a Python function that initializes two integer variables `a` and `b` such that their sum is an odd number. The function should then compute the product of these two variables, find the square root of the product, and round it to the nearest integer. Finally, the function should return the rounded result.
The cod... | Here is the Python code to solve the given problem in the markdown block:
```python
import math
def compute_final_result(a: int, b: int) -> int:
"""
Computes the final result by initializing two integers `a` and `b` such that their sum is odd,
then computing the product of these two integers, finding the s... |
python_sharegpt_23k | 22,147 | Write a Python function to generate a random French musical term from a predefined list of terms. The function should return the randomly selected term as a string. The code should start with:
```python
from typing import List
import random
def generate_random_french_musical_term(terms: List[str]) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_french_musical_term(terms: List[str]) -> str:
"""
Generates a random French musical term from a given list of terms.
Args:
terms (List[str]): A list of Fren... |
python_sharegpt_23k | 22,148 | Write a Python function to generate a unique identifier for a new laptop model using the manufacturer name, screen size, and processor type. The identifier should be formatted as follows:
- The manufacturer name should be truncated to the first 6 characters.
- The screen size should be rounded to one decimal place.
- T... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_laptop_identifier(manufacturer: str, screen_size: float, processor_type: str) -> str:
"""
Generates a unique identifier for a new laptop model using the manufacturer name, screen size, and processor type.
Args:... |
python_sharegpt_23k | 22,150 | Write a Python function to generate a list of different modes of transportation that can be used to travel from one city to another. The function should accept two parameters: the starting city and the destination city. The function should return a list of modes of transportation that can be used for the journey. The l... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def get_modes_of_transportation(start_city: str, destination_city: str) -> List[str]:
"""
Generates a list of different modes of transportation that can be used to travel from the start city to the desti... |
python_sharegpt_23k | 22,153 | Write a Python function to reverse a given string. The function should take a string as input and return the reversed version of the string. The code should start with:
```python
def reverse_string(string: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
def reverse_string(string: str) -> str:
"""
Reverses the given string.
Args:
string (str): The input string to be reversed.
Returns:
str: The reversed version of the input string.
"""
# Use sl... |
python_sharegpt_23k | 22,158 | 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 | 22,160 | 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 | 22,161 | 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 list_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.
Returns... |
python_sharegpt_23k | 22,163 | Write a Python function to generate a random story about a brave young girl and her adventure. The function should create a plot and characters for the story, and then print the story in a structured format. The story should include a protagonist (the brave young girl), an antagonist (a villain), and a series of plot p... | Here is the Python code to solve the given problem in the markdown block:
```python
import random
def generate_story():
"""
Generates a random story about a brave young girl and her adventure.
The story includes a protagonist (the brave young girl), an antagonist (a villain),
and a series of plot poin... |
python_sharegpt_23k | 22,169 | 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 | 22,177 | Write a Python function to calculate the sum of the squares of all the odd numbers between 1 and a given positive integer `n`, inclusive. The function should return a list of tuples, where each tuple contains an odd number, its square, and the running sum of the squares up to that number. The function should also ensur... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def sum_of_squares_of_odds(n: int) -> List[Tuple[int, int, int]]:
"""
Calculate the sum of the squares of all the odd numbers between 1 and n, inclusive.
Args:
n (int): The upper limi... |
python_sharegpt_23k | 22,179 | Write a Python function to calculate the sum of all integers in a given list. The function should handle lists of any length, including empty lists. The function should return the sum of the integers in the list.
The code should start with:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> int:
"""
Calculate the sum of all integers in the given list.
Args:
numbers (List[int]): A list of integers for which the sum is to be calculated.
... |
python_sharegpt_23k | 22,182 | Write a Python function to sort a given list of words in ascending order based on their ASCII values and return both the sorted list and the reverse sorted list. The function should handle any list of strings and return two lists: one sorted in ascending order and the other in descending order.
The code should start w... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def sort_words_by_ascii(words: List[str]) -> Tuple[List[str], List[str]]:
"""
Sorts a given list of words in ascending order based on their ASCII values and returns both the sorted list and the re... |
python_sharegpt_23k | 22,194 | Write a Python function to generate an HTML string that displays a sentence containing the words "blue", "apple", and "school". The word "apple" should be displayed in blue font color, while the words "blue" and "school" should be displayed in black. The function should accept the words as input parameters and return t... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_html_sentence(blue_word: str, apple_word: str, school_word: str) -> str:
"""
Generates an HTML string that displays a sentence with specific words colored differently.
Args:
blue_word (str): The word to... |
python_sharegpt_23k | 22,195 | 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 | 22,201 | 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 a given sentence by replacing specific phrases with semantically equivalent phrases.
Args:
sentence (str): The original sentence to be rewritten.
Returns... |
python_sharegpt_23k | 22,204 | Write a Python function to calculate the average of an array of integers. The function should handle an empty array by returning `None` instead of raising an error. 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 | 22,206 | Write a Python function to reverse an array of integers that includes both positive and negative integers. The function should take a list of integers as input and return the reversed list. The code should start with:
```python
from typing import List
def reverse_array(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 reverse_array(arr: List[int]) -> List[int]:
"""
Reverses an array of integers in place.
Args:
arr (List[int]): The array of integers to be reversed.
Returns:
List[int]: The ... |
python_sharegpt_23k | 22,207 | Write a Python function to calculate the exact date that is a specified number of days after the current date. The function should take an integer `days` as input and return the future date as a `datetime.date` object. The code should start with:
```python
import datetime
def calculate_future_date(days: int) -> dateti... | Here is the Python code to solve the given problem in the markdown block:
```python
import datetime
def calculate_future_date(days: int) -> datetime.date:
"""
Calculate the exact date that is a specified number of days after the current date.
Args:
days (int): The number of days to add to the curr... |
python_sharegpt_23k | 22,209 | 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 | 22,214 | Write a Python function to add a suffix to a given word and return the new word. The function should handle cases where the suffix is an empty string or the word is an empty string. The code should start with:
```python
def add_suffix(word: str, suffix: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def add_suffix(word: str, suffix: str) -> str:
"""
Adds a suffix to a given word and returns the new word.
Args:
word (str): The base word to which the suffix will be added.
suffix (str): The suffix to be ad... |
python_sharegpt_23k | 22,217 | 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 formatted string... | Here is the Python code to solve the given problem in the markdown block:
```python
def describe_special_place() -> str:
"""
Describes a place that holds special significance, including its name, location, description, sensory experiences, and historical or cultural significance.
Returns:
str: A fo... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.