Generate several functions on Python If Statements, including type hint and comments
- User
Generate several functions on Python If Statements, including type hint and comments
- Assistant
Here are a few examples of if statements in Python, with type hints and comments:
pythondef is_positive(number: int) -> bool: """ Returns True if the given number is positive, False otherwise. """ if number > 0: return True else: return False def get_sign(number: int) -> str: """ Returns the sign of the given number as a string. """ if number > 0: return "Positive" elif number < 0: return "Negative" else: return "Zero" def max_of_three(a: int, b: int, c: int) -> int: """ Returns the maximum of three given numbers. """ if a > b and a > c: return a elif b > a and b > c: return b else: return c - User
Convert the code for each function into programming challenge with an introduction, requirements, and summary
- Assistant
Here is the format for each of the functions:
Function:
is_positiveIntroduction
Write a function
is_positivethat takes an integernumberas input and returnsTrueif the given number is positive, andFalseotherwise.Requirements
- The input integer
numbercan be any integer within the range of Python'sinttype. - The function should return
Trueif the inputnumberis positive (greater than 0), andFalseotherwise.
- The input integer
- User
Generate test code of each function using unittest
- Assistant
Here is an example of test code for each of the functions using
unittestin Python:scss
Other models, same or similar prompt
Responses were produced in different, uncontrolled contexts (system prompts, settings, prior turns). This is not a benchmark.