1+ custom_power = lambda x = 0 , / , e = 1 : x ** e
2+
3+ def custom_equation (x : int = 0 , y : int = 0 , / , a : int = 1 , b : int = 1 , * , c : int = 1 ) -> float :
4+ """
5+ This function computes the result of the expression (x**a + y**b) / c.
6+
7+ :param x: The base for the first exponentiation. Positional-only.
8+ :type x: int
9+ :param y: The base for the second exponentiation. Positional-only.
10+ :type y: int
11+ :param a: The exponent for x. Positional-or-keyword.
12+ :type a: int
13+ :param b: The exponent for y. Positional-or-keyword.
14+ :type b: int
15+ :param c: The divisor. Keyword-only. Defaults to 1.
16+ :type c: int
17+ :returns: The result of the calculation.
18+ :rtype: float
19+
20+ """
21+ return (custom_power (x ,a ) + custom_power (y ,b ))/ c
22+
23+ def fn_w_counter () -> tuple [int , dict [str , int ]]:
24+ if not hasattr (fn_w_counter , "count" ):
25+ setattr (fn_w_counter , "count" , 0 )
26+ fn_w_counter .count += 1
27+ temp_dict = {}
28+ temp_dict [(str )(__name__ )] = fn_w_counter .count
29+ temp_tuple = (fn_w_counter .count , temp_dict )
30+ return temp_tuple
31+
32+ if __name__ == "__main__" :
33+ print (custom_power (2 ,3 ))
34+ print (custom_power (2 ,e = 3 ))
35+ print (custom_equation (2 , 2 , a = 3 , b = 3 ,c = 1 ))
36+ for i in range (5 ):
37+ fn_w_counter ()
38+ print (fn_w_counter ())
0 commit comments