Write a function point_position_relative_to_line(a, b, c, x, y) -> int that determines the position of a point (x, y) with respect to a line described by the equation ax + by + c = 0.
The function should return:
+1 if the point is above the line
-1 if the point is below the line
0 if the point is on the line
A point (x, y) is considered on the line if substituting x and y into the equation results in 0. A point is above the line if the value of ax + by + c > 0 and below the line if ax + by + c < 0.
>>> point_position_relative_to_line(1, -1, 0, 2, 1)
>>> point_position_relative_to_line(-1, -1, -1, 0, 0)
-1
>>> point_position_relative_to_line(2, -1, -4, 2, 0)
Implement this function:
def point_position_relative_to_line(a, b, c, x, y) -> int:
Write the function only — the arguments are read for you and the return value is printed automatically.
Arguments arrive as one Python literal per line, in this order: a, b, c, x, y.
Input
1
-1
0
2
1
Output
1
Write a function point_position_relative_to_line(a, b, c, x, y) -> int that determines the position of a point (x, y) with respect to a line described by the equation ax + by + c = 0. The function should return: +1 if the point is above the line\ -1 if the point is below the line\ 0 if the point is on the line ### Note A point (x, y) is considered on the line if substituting x and y into the equation results in 0. A point is above the line if the value of ax + by + c > 0 and below the line if ax + by + c < 0. ### Example ``` >>> point_position_relative_to_line(1, -1, 0, 2, 1) >>> point_position_relative_to_line(-1, -1, -1, 0, 0) -1 >>> point_position_relative_to_line(2, -1, -4, 2, 0) ``` ## Your task Implement this function: ```python def point_position_relative_to_line(a, b, c, x, y) -> int: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `a`, `b`, `c`, `x`, `y`. ## Example **Input** ``` 1 -1 0 2 1 ``` **Output** ``` 1 ``` Write a function expand_sum_of_products(expr: str) -> str that takes a string representation of a product of sum of two terms in the form "(a+b)(c+d)", and expands it into the sum of products in the form "a*c + a*d + b*c + b*d". The output should be a properly formatted string of the expanded form. The input can have spaces in between the symbols and operators. The spacing and ordering of the terms should be exacty as given in the format. There will be always + sign between the values in a term. ### Example ``` >>> expand_sum_of_products("(a+b)(c+d)") "a*c + a*d + b*c + b*d" >>> expand_sum_of_products("(x+y)(z+w)") "x*z + x*w + y*z + y*w" >>> expand_sum_of_products("(1+5)(10+12)") "1*10 + 1*12 + 5*10 + 5*12" ``` ## Your task Implement this function: ```python def expand_sum_of_products(expr: str) -> str: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `expr`. ## Example **Input** ``` "(a+b)(c+d)" ``` **Output** ``` 'a*c + a*d + b*c + b*d' ``` Write a function repeat_second_half(t) that takes a tuple t and returns a new tuple where the second half of the original tuple is repeated after the first half. If the tuple has an odd number of elements, the middle element should be included in the first half. ### Constraints The input tuple will contain at least two elements.\ The elements in the tuple can be of any type (integers, strings, etc.). NOTE: This is a function type question; you don't have to take input or print the output, just have to complete the required function definition. ### Example ``` >>> repeat_second_half((1, 2, 3, 4, 5)) (1, 2, 3, 4, 5, 4, 5) >>> repeat_second_half((10, 20, 30, 40)) (10, 20, 30, 40, 30, 40) >>> repeat_second_half(('a', 'b', 'c', 'd', 'e', 'f')) ('a', 'b', 'c', 'd', 'e', 'f', 'd', 'e', 'f') >>> repeat_second_half((1, 2, 3)) (1, 2, 3, 3) ``` ## Your task Implement this function: ```python def repeat_second_half(t: tuple) -> tuple: ``` Write the function only — the arguments are read for you and the return value is printed automatically. **Arguments** arrive as one Python literal per line, in this order: `t`. ## Example **Input** ``` (1, 2, 3, 4, 5) ``` **Output** ``` (1, 2, 3, 4, 5, 4, 5) ```