source stringclasses 6
values | id int64 0 111k | instruction stringlengths 167 4.39k | response stringlengths 244 6.1k |
|---|---|---|---|
python_sharegpt_23k | 19,092 | Write a Python function to sort a list of movie titles by their release date and display the genres of each movie. Additionally, create a table that lists the runtime of each movie, and only display movies with a runtime of at least 90 minutes. The function should start with:
```python
from typing import List, Tuple
d... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
def sort_and_display_movies(movies: List[Tuple[str, int, str, int]]) -> None:
"""
Sorts a list of movie titles by their release date and displays the genres of each movie.
Additionally, create... |
python_sharegpt_23k | 19,093 | 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 | 19,096 | Write a Python function to determine which students in a given list are not considered intelligent. Each student is represented by a dictionary with keys "name" and "intelligence", where "intelligence" is a boolean value. The function should return a list of names of students who are not intelligent.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def find_not_intelligent_students(students: List[Dict[str, any]]) -> List[str]:
"""
Determine which students in a given list are not considered intelligent.
Args:
students (List[Dict[s... |
python_sharegpt_23k | 19,098 | Write a Python function to generate a new list with unique elements from a given list of integers, while preserving the order of their first occurrence. The function should start with:
```python
from typing import List
def unique_elements_preserve_order(lst: List[int]) -> List[int]:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
def unique_elements_preserve_order(lst: List[int]) -> List[int]:
"""
Generate a new list with unique elements from the given list of integers, preserving the order of their first occurrence.
Args:... |
python_sharegpt_23k | 19,100 | Write a Python function to generate an HTML string that displays a sentence containing the words "blue", "apple", and "school". The word "apple" should be displayed in blue font color, while the words "blue" and "school" should be displayed in black font color. The function should accept three strings as input paramete... | Here is the Python code to solve the given problem in the markdown block:
```python
def generate_html_sentence(word1: str, word2: str, word3: str) -> str:
"""
Generates an HTML string that displays a sentence with specific words colored differently.
Args:
word1 (str): The first word, which will be ... |
python_sharegpt_23k | 19,104 | Write a Python function named `drastically_gradually` that takes a list of numbers as input and gradually increases each number by 5, then drastically decreases them by 10. The function should return the final list.
The code should start with:
```python
from typing import List
def drastically_gradually(lst: List[int]... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def drastically_gradually(lst: List[int]) -> List[int]:
"""
Transforms a list of numbers by gradually increasing each number by 5 and then drastically decreasing them by 10.
Args:
lst (List[... |
python_sharegpt_23k | 19,112 | Write a Python function that multiplies each element of a given list by a specified scalar if a boolean flag is set to `True`. If the boolean flag is `False`, the function should return the original list unchanged. The function should handle lists of integers and ensure that the scalar is an integer.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def multiply_list_by_scalar(lst: List[int], scalar: int, should_multiply: bool) -> List[int]:
"""
Multiplies each element of a given list by a specified scalar if the boolean flag is True.
If the boo... |
python_sharegpt_23k | 19,114 | Write a Python function to generate a greeting message with a randomly selected name from a predefined list of names, and append an exclamation mark to the end of the greeting string. The function should return the greeting string.
The code should start with:
```python
from typing import List
import random
def genera... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_greeting(names: List[str]) -> str:
"""
Generates a greeting message with a randomly selected name from a list of names,
and appends an exclamation mark to the end of the gr... |
python_sharegpt_23k | 19,119 | Write a Python function to rearrange the words in a given text string in alphabetical order. The function should use the Python built-in function `sorted()` to achieve this. The function should start with:
```python
def sort_words_alphabetically(text: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sort_words_alphabetically(text: str) -> str:
"""
Rearranges the words in a given text string in alphabetical order.
Args:
text (str): The input text string containing words to be sorted.
Returns:
st... |
python_sharegpt_23k | 19,121 | Write a Python function to generate a list of n random activities to do during self-isolation. The list should include a mix of indoor and outdoor activities, ensuring that no activity involves social gatherings. The function should start with:
```python
from typing import List
def generate_random_activities(n: int) -... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_activities(n: int) -> List[str]:
"""
Generates a list of n random activities to do during self-isolation.
The list includes a mix of indoor and outdoor activities, e... |
python_sharegpt_23k | 19,123 | Write a Python function to extract all email addresses from a given text string. The function should use regular expressions to identify and return a list of all valid email addresses found in the text.
The code should start with:
```python
from typing import List
import re
def extract_emails(text: str) -> List[str]:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_emails(text: str) -> List[str]:
"""
Extracts all email addresses from the given text string.
Args:
text (str): The text string from which to extract email addresses.
... |
python_sharegpt_23k | 19,126 | Write a Python function to calculate the expression `10 + 2n` for a given range of values of `n` and determine whether each result is even or odd. The function should return a list of strings where each string contains the result followed by either "EVEN" or "ODD". The function 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 calculate_and_classify(start: int, end: int) -> List[str]:
"""
Calculate the expression 10 + 2n for each integer n in the range [start, end] and classify each result as even or odd.
Args:
... |
python_sharegpt_23k | 19,135 | 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 the given array of integers in place.
Args:
arr (List[int]): The array of integers to be reversed.
Returns:
List[int... |
python_sharegpt_23k | 19,136 | Write a Python function to find all strings in a list that contain either 'cat' or 'dog' using regular expressions. The function should return a list of all such strings.
The code should start with:
```python
from typing import List
import re
def find_strings_with_cat_or_dog(strings: List[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 find_strings_with_cat_or_dog(strings: List[str]) -> List[str]:
"""
Find all strings in a list that contain either 'cat' or 'dog' using regular expressions.
Args:
strings (List[... |
python_sharegpt_23k | 19,140 | Write a Python function to calculate the total profit for a store given the total revenue, cost of goods sold, operating expenses, and taxes. The function should return the profit as a float. Additionally, provide a detailed explanation of the factors that contribute to the final profit value.
The code should start wi... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_profit(total_revenue: float, cost_of_goods_sold: float, operating_expenses: float, taxes: float) -> float:
"""
Calculate the total profit for a store given the total revenue, cost of goods sold, operating expenses,... |
python_sharegpt_23k | 19,143 | 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 | 19,155 | Write a Python function to reverse a given string. The function should handle strings of any length, including empty strings. The function should be efficient and should not use any built-in string reversal methods directly. Instead, it should use a loop to reverse the string manually.
The code should start with:
```p... | 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 manually without using built-in reversal methods.
Args:
s (str): The input string to be reversed.
Returns:
str: The reversed string.
... |
python_sharegpt_23k | 19,161 | Write a Python function to find the longest palindromic substring within a given string. The function should handle strings with both uppercase and lowercase letters, as well as special characters and spaces. The function should be efficient and effective for even the longest and most complex strings. The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
def longest_palindromic_substring(s: str) -> str:
"""
Find the longest palindromic substring within a given string.
Args:
s (str): The input string to search for the longest palindrome.
Returns:
str: Th... |
python_sharegpt_23k | 19,164 | Write a Python function to calculate the sum of all integers in a given list. The function should handle lists of any length, including empty lists. The function should return the sum of the integers in the list.
The code should start with:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> in... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> int:
"""
Calculate the sum of all integers in the given list.
Args:
numbers (List[int]): A list of integers.
Returns:
int: The sum of al... |
python_sharegpt_23k | 19,170 | Write a Python function to identify the three numbers in a given list of integers that have the largest sum, excluding any negative numbers. The function should have a time complexity of O(n log n) or better.
The code should start with:
```python
from typing import List
def find_three_largest_sum(numbers: List[int]) ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_three_largest_sum(numbers: List[int]) -> List[int]:
"""
Identifies the three numbers in a given list of integers that have the largest sum, excluding any negative numbers.
Args:
num... |
python_sharegpt_23k | 19,176 | 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 lists of varying lengths and word lengths.
The code should start with:
```python
from typing import List
def sort_words_by_ascii(... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_words_by_ascii(words: List[str]) -> (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 reverse sorted... |
python_sharegpt_23k | 19,177 | 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 | 19,179 | Write a Python function to reverse the characters in a given string and return the reversed string. The function should only use built-in Python functions and should not use any third-party libraries or packages. The code should start with:
```python
def reverse_string(word: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def reverse_string(word: str) -> str:
"""
Reverses the characters in the given string and returns the reversed string.
Args:
word (str): The input string to be reversed.
Returns:
str: The reversed strin... |
python_sharegpt_23k | 19,183 | Write a Python function to generate a tryptic joke about a popular movie, utilizing wordplay, puns, and references to popular culture. The function should take a movie title, a hero, a villain, a weapon, and a team as inputs and return a list of three jokes. Each joke should be structured in a way that incorporates the... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def generate_tryptic_joke(movie: str, hero: str, villain: str, weapon: str, team: str) -> List[Tuple[str, str, str, str, str]]:
"""
Generates a tryptic joke about a popular movie, ut... |
python_sharegpt_23k | 19,184 | 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 both directions of conversion (kilograms to pounds and pounds to kilograms) and provide the weight on the moo... | 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 | 19,185 | 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
from typing import Tuple
import random
import string
def generate_outdoor_classroom_code() -> Tuple[str, int, int]:
"""
Generates a random code for an outdoor classroom door lock.
The code consists of four characters: two ... |
python_sharegpt_23k | 19,186 | 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,192 | 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 | 19,194 | Write a Python function to correct common typos in a given text using regular expressions. The function should identify and correct common errors 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_t... | 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 the given text using regular expressions.
Args:
text (str): The input text containing potential typos.
Returns:
str: The corr... |
python_sharegpt_23k | 19,197 | Write a Python function to generate a list of five items that would make a perfect picnic lunch. The function should randomly select five food items from a predefined list and pair each food item with a randomly selected drink item from another predefined list. The final output should be a formatted string that lists t... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_picnic_lunch() -> str:
"""
Generates a list of five items that would make a perfect picnic lunch.
Each food item is paired with a randomly selected drink item.
Returns... |
python_sharegpt_23k | 19,201 | Write a Python function to generate a greeting message with a randomly selected name from a predefined list of names, and append an exclamation mark to the end of the greeting string. The function should return the greeting string.
The code should start with:
```python
from typing import List
import random
def genera... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_greeting(names: List[str]) -> str:
"""
Generates a greeting message with a randomly selected name from a list of names,
and appends an exclamation mark to the end of the gr... |
python_sharegpt_23k | 19,202 | 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 apply_formula_to_list(nums: List[int], formula) -> List[int]:
"""
Applies a given mathematical formula to each element of a list of integers using the map() function.
Args:
nums (List[in... |
python_sharegpt_23k | 19,207 | 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(input_list: List[int]) -> List[int]:
"""
Extracts unique elements from the given list while preserving the order of their first appearance.
Args:
input_list (List... |
python_sharegpt_23k | 19,210 | 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 | 19,211 | Write a Python function to convert a traditional Italian tiramisu recipe into a vegan version by replacing non-vegan ingredients with their vegan alternatives. The function should take a list of ingredients as input and return a new list with the appropriate substitutions. 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
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 their vegan alternative... |
python_sharegpt_23k | 19,215 | 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 | 19,216 | Write a Python function to calculate the total amount after deducting the sales tax from a given subtotal. The function should take the subtotal and the tax rate as inputs and return the total amount after applying the tax deduction. The code should start with:
```python
def calculate_total_after_tax(subtotal: float, t... | 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 a given subtotal.
Args:
subtotal (float): The initial amount before tax ded... |
python_sharegpt_23k | 19,218 | 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 string format and a target date in string format, and return the missing word in the sentence "The sun rose _____ the horizon on [target date]." The missing word should be th... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import datetime
def find_missing_word(sunrise_times: List[str], target_date: str) -> str:
"""
Finds the missing word in the sentence "The sun rose _____ the horizon on [target date]."
using a list of... |
python_sharegpt_23k | 19,220 | 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_to_word(word: str, suffix: str) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def add_suffix_to_word(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 ... |
python_sharegpt_23k | 19,223 | 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 check.
Returns:
str: "Even" if the number is even, "Odd" if the number is... |
python_sharegpt_23k | 19,225 | Write a Python function to generate a random zodiac sign belonging to the fire element. The function should return the name of the randomly selected zodiac sign. 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 the randomly selected fire element zodiac sign.... |
python_sharegpt_23k | 19,228 | 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... |
python_sharegpt_23k | 19,238 | 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 this is a test", the output should be "test a is this world Hello". The function should handle strings with multiple spaces between words and leading/trailing spaces.... | 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 | 19,239 | 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 generated list is unique and contains exactly one item from each category.
The code should start ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_rare_items() -> List[str]:
"""
Generates a list of five rare items, one from each predefined category.
Returns:
List[str]: A list containing exactly one randomly s... |
python_sharegpt_23k | 19,241 | Write a Python function to generate a haiku verse that includes a noun, adjective, and verb from specific categories. The haiku should adhere to the traditional structure of three lines with 5, 7, and 5 syllables respectively. The function should randomly select words from the provided lists of nouns, adjectives, and v... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_haiku(nouns: List[str], adjectives: List[str], verbs: List[str]) -> str:
"""
Generates a haiku verse using randomly selected words from the provided lists of nouns, adjectives,... |
python_sharegpt_23k | 19,247 | 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_and_print`.
The code should start with:
```python
def sum_and_print(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def sum_and_print(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: The... |
python_sharegpt_23k | 19,250 | 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 | 19,251 | 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 | 19,252 | 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 keys 'bur... | 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 that live in underground burrows in the African sava... |
python_sharegpt_23k | 19,254 | 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 | 19,283 | 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 ... |
python_sharegpt_23k | 19,289 | 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:
"""
Convert a given temperature in Celsius to Fahrenheit.
Args:
celsius (float): The temperature in Celsius to be converted.
Returns:
float: The tempe... |
python_sharegpt_23k | 19,290 | 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 | 19,292 | 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 | 19,298 | 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:
"""
Convert a fraction into its decimal equivalent.
Args:
numerator (int): The numerator of the fraction.
denominator (int): The denominato... |
python_sharegpt_23k | 19,299 | Write a Python function to generate a random string of a specified length using a combination of uppercase letters, lowercase letters, and digits. The function should allow the user to optionally specify the characters to be included in the random string. If no characters are specified, the function should use the defa... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Optional, List
import random
import string
def generate_random_string(length: int, characters: Optional[List[str]] = None) -> str:
"""
Generates a random string of the specified length using the provided char... |
python_sharegpt_23k | 19,305 | Write a Python function to generate a random title for a story about a family's journey to a beach town. The function should randomly select a title format and fill it with randomly chosen adjectives, nouns, and places from predefined lists. The function should return the generated title as a string.
The code should s... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import random
def generate_random_title() -> str:
"""
Generates a random title for a story about a family's journey to a beach town.
Returns:
str: A randomly generated title.
"""
# L... |
python_sharegpt_23k | 19,307 | Write a Python function to extract all email addresses from a given text string. The function should use regular expressions to identify and return a list of all valid email addresses found in the text.
The code should start with:
```python
from typing import List
import re
def extract_emails(text: str) -> List[str]:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
import re
def extract_emails(text: str) -> List[str]:
"""
Extracts all valid email addresses from a given text string.
Args:
text (str): The input text string from which to extract email add... |
python_sharegpt_23k | 19,308 | Write a Python function to reverse an array of integers that includes both positive and negative integers. The function should return the reversed array. 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.
Args:
arr (List[int]): The array of integers to be reversed.
Returns:
List[int]: The reversed ... |
python_sharegpt_23k | 19,310 | Write a Python function to calculate the time difference in seconds between the current date and time and the exact moment when Neil Armstrong first set foot on the Moon's surface, considering the time zone differences. The function should also return a list of fascinating yet less popular facts or events linked to the... | Here is the Python code to solve the given problem in the markdown block:
```python
import datetime
from typing import List
def time_difference_to_moon_landing() -> (float, List[str]):
"""
Calculate the time difference in seconds between the current date and time and the exact moment when Neil Armstrong first ... |
python_sharegpt_23k | 19,316 | 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 riddle_with_color_clue() -> str:
"""
Generates a random color in RGB format and provides a clue to the answer of a riddle based on the color.
The riddle is: "I am vast and constantly shifting, my magnific... |
python_sharegpt_23k | 19,317 | Write a Python function to arrange a list of words in alphabetical order and then output the resulting sentence as a string. The function should handle lists of varying lengths and ensure that the words are sorted lexicographically. The code should start with:
```python
from typing import List
def sort_sentence(words:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_sentence(words: List[str]) -> str:
"""
Arranges a list of words in alphabetical order and returns the resulting sentence as a string.
Args:
words (List[str]): A list of words to be ... |
python_sharegpt_23k | 19,318 | 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 | 19,322 | 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 | 19,332 | 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.
The workout consists of 5 cycles, each lasting 6 minutes. In each cycle, the client alternates between runnin... |
python_sharegpt_23k | 19,336 | Write a Python function to sort a list of words in ascending order based on their length, and then in alphabetical order. The function should be efficient enough to handle lists with up to 10,000 words and sort them within a reasonable time frame. The code should start with:
```python
from typing import List
def sort_... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def sort_words_by_length_and_alphabet(words: List[str]) -> List[str]:
"""
Sorts a list of words in ascending order based on their length, and then in alphabetical order.
Args:
words (List[st... |
python_sharegpt_23k | 19,341 | Write a Python function to calculate the age of a person when they completed a significant work, given their birth year and the year they completed the work. The function should return the age as an integer.
The code should start with:
```python
def calculate_age_at_completion(birth_year: int, completion_year: int) ->... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_age_at_completion(birth_year: int, completion_year: int) -> int:
"""
Calculate the age of a person when they completed a significant work.
Args:
birth_year (int): The year the person was born.
... |
python_sharegpt_23k | 19,342 | Write a Python function to generate a random French musical term from a predefined list of terms. The function should return the randomly selected term as a string. The code should start with:
```python
from typing import List
import random
def generate_random_french_term(terms: List[str]) -> str:
```
| Here is the Python code to solve the given problem in the markdown block:
:
```python
from typing import List
import random
def generate_random_french_term(terms: List[str]) -> str:
"""
Generates a random French musical term from a given list of terms.
Args:
terms (List[str]): A list of French mus... |
python_sharegpt_23k | 19,349 | Write a Python function to calculate the number of times a piece of paper, initially 0.1 millimeters thick, needs to be folded to reach a specified thickness in meters. The function should take the target thickness in meters as an argument and return the number of folds required.
The code should start with:
```python
... | Here is the Python code to solve the given problem in the markdown block:
```python
def calculate_folds_to_reach_thickness(target_thickness: float) -> int:
"""
Calculate the number of times a piece of paper, initially 0.1 millimeters thick,
needs to be folded to reach a specified thickness in meters.
A... |
python_sharegpt_23k | 19,350 | Write a Python function to identify the top 3 bodies of water with the most severe water pollution, taking into account the population living in the vicinity of the body of water. The dataset is a list of dictionaries, where each dictionary contains the following fields:
- "name": the name of the body of water
- "regio... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Dict
def top_3_polluted_bodies_of_water(data: List[Dict[str, any]]) -> List[str]:
"""
Returns the names of the top 3 bodies of water with the most severe water pollution,
taking into account the pop... |
python_sharegpt_23k | 19,352 | 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 | 19,363 | 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 | 19,364 | Write a Python function that generates a random idiom from a predefined list of idioms and returns both the idiom and its meaning. The function should handle a list of idioms and their meanings, and it should randomly select one idiom along with its meaning. 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, Tuple
import random
def get_random_idiom(idioms: List[Tuple[str, str]]) -> Tuple[str, str]:
"""
Randomly selects an idiom from a given list of idioms and returns both the idiom and its meaning.
Arg... |
python_sharegpt_23k | 19,366 | 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 should 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 s... | 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 | 19,374 | Write a Python function to find the intersection of two given lists, i.e., the elements that are present in both lists. The function should handle lists with duplicate elements and return a list of unique intersecting elements. The code should start with:
```python
from typing import List
def find_intersection(list1: ... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def find_intersection(list1: List[int], list2: List[int]) -> List[int]:
"""
Find the intersection of two lists, i.e., the elements that are present in both lists.
Args:
list1 (List[int]): Th... |
python_sharegpt_23k | 19,378 | Write a Python function to convert a list of items into a grammatically correct sentence. The sentence should start with "I have ", followed by the items separated by commas, and the last item should be preceded by "and". The sentence should end with " in my basket."
The code should start with:
```python
from typing i... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def items_to_sentence(items: List[str]) -> str:
"""
Converts a list of items into a grammatically correct sentence.
Args:
items (List[str]): A list of strings representing items.
Return... |
python_sharegpt_23k | 19,383 | Write a Python function to calculate the sum of all integers in a given list. The function should handle lists of any size, 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]) -> int:... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_sum(numbers: List[int]) -> int:
"""
Calculate the sum of all integers in the given list.
Args:
numbers (List[int]): A list of integers.
Returns:
int: The sum of al... |
python_sharegpt_23k | 19,394 | 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 | 19,395 | Write a Python function to perform integer division and calculate the remainder of the division of two given integers. The function should return the quotient and print the remainder. The code should start with:
```python
def integer_division_with_remainder(num1: int, num2: int) -> int:
```
| Here is the Python code to solve the given problem in the markdown block:
```python
def integer_division_with_remainder(num1: int, num2: int) -> int:
"""
Performs integer division of two integers and prints the remainder.
Args:
num1 (int): The dividend.
num2 (int): The divisor.
Returns... |
python_sharegpt_23k | 19,396 | Write a Python function to generate a random story about a brave young girl and a villain. 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 beginning, middle, and end, with plot points that describe the girl's journey and her int... | 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 a villain.
The story includes a beginning, middle, and end, with plot points that describe the girl's journey and her interactio... |
python_sharegpt_23k | 19,400 | 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 sorted list of unique integers in descending order. The code should start with:
```python
from typing import List
def sort_and_remove_duplicates(lst: List[... | 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 | 19,411 | Write a Python function to calculate the total distance traveled by birds over a given number of days. The function should take a list of integers representing the distances traveled each day and return the total distance.
The code should start with:
```python
from typing import List
def calculate_total_distance(dist... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def calculate_total_distance(distances: List[int]) -> int:
"""
Calculate the total distance traveled by birds over a given number of days.
Args:
distances (List[int]): A list of integers rep... |
python_sharegpt_23k | 19,413 | 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 | 19,414 | 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 | 19,416 | Write a Python function to categorize a given word as an adverb based on common English grammar rules. The function should check if the word ends with "ly" and, if not, should use a predefined list of common adverbs that do not end with "ly" to determine if the word is an adverb. The function should return a boolean va... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List
def is_adverb(word: str, common_adverbs: List[str] = None) -> bool:
"""
Determines if a given word is an adverb based on common English grammar rules.
Args:
word (str): The word to be catego... |
python_sharegpt_23k | 19,419 | Write a Python function to generate a random word from a list of English words that have the same meaning as the German word "Verantwortung" and use it in a sentence. The function should also return a brief explanation of the etymology and cultural connotations of the chosen word, along with an example sentence demonst... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import List, Tuple
import random
def generate_random_word_and_sentence(words: List[Tuple[str, str, str]]) -> Tuple[str, str, str]:
"""
Generates a random word from a list of English words that have the same meaning ... |
python_sharegpt_23k | 19,421 | 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 | 19,424 | 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 data points based on the given rule and return the count of each classification.
Args:
... |
python_sharegpt_23k | 19,428 | Write a Python function to check if a given string contains any substring that is a palindrome of a specified minimum length. The function should return `True` if such a substring exists, otherwise `False`. The function should be efficient and avoid unnecessary computations.
The code should start with:
```python
def c... | Here is the Python code to solve the given problem in the markdown block:
```python
def contains_palindrome(s: str, min_length: int) -> bool:
"""
Check if the given string contains any substring that is a palindrome of the specified minimum length.
Args:
s (str): The input string to check for palin... |
python_sharegpt_23k | 19,434 | 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_and_form_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 | 19,436 | 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 | 19,445 | 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 | 19,453 | 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 | 19,454 | 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 | 19,456 | Write a Python function to generate a random Shakespearean insult along with its meaning. The function should randomly select an insult from a predefined list of insults and their meanings, and return both the insult and its meaning as a tuple. The code should start with:
```python
from typing import Tuple
import rando... | Here is the Python code to solve the given problem in the markdown block:
```python
from typing import Tuple
import random
def generate_insult() -> Tuple[str, str]:
"""
Generates a random Shakespearean insult along with its meaning.
Returns:
Tuple[str, str]: A tuple containing the randomly selecte... |
python_sharegpt_23k | 19,462 | 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:
"""
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 | 19,464 | 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 | 19,467 | 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 | 19,469 | 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 should be efficient in terms of both time and space complexity.
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 to remove alp... |
python_sharegpt_23k | 19,470 | 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... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.