Skip to content

Commit a02cec1

Browse files
authoredDec 11, 2024
Merge pull request #211 from myr2001/master
HW 3 Sinem Gençer
2 parents 44f3847 + 0212284 commit a02cec1

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed
 

‎Week03/functions_sinem_gencer.py

+50
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
1+
from typing import Tuple, Dict
2+
3+
custom_power = lambda x=0, /, e=1 : x**e
4+
"""
5+
Function to take power of a value.
6+
:param x: Value that is being taken the power of.
7+
:type x: float
8+
:param e: Value that is the power.
9+
:type e: float
10+
:return: The result of equation x^e
11+
"""
12+
13+
def custom_equation(x: int = 0, y: int = 0, /, a: int = 1, b: int = 1, *, c: int = 1) -> float:
14+
"""
15+
Function to calculate an equation and return float type value.
16+
:param x: Default value 0, positional-only.
17+
:type x: int
18+
:param y: Default value 0, positional-only.
19+
:type y: int
20+
:param a: Default value 1, positional and keyword.
21+
:type a: int
22+
:param b: Default value 1, positional and keyword.
23+
:type b: int
24+
:param c: Default value 1, keyword only.
25+
:type c: int
26+
:return: The result of equation.
27+
:rtype: float
28+
"""
29+
return (x**a + y**b) / c
30+
31+
caller_counts = {}
32+
33+
def fn_w_caller() -> Tuple[int, Dict[str, int]]:
34+
"""
35+
Function to return the number of calls with caller information.
36+
:return: A tuple containing an integer (total number of calls) and a dictionary (key: caller __name__, value: number of calls)
37+
:rtype: Tuple[int, Dict[str, int]]
38+
"""
39+
caller_name = __name__
40+
caller_counts[caller_name] = caller_counts.get(caller_name, 0) + 1
41+
total_calls = sum(caller_counts.values())
42+
return total_calls, {caller_name: caller_counts[caller_name]}
43+
44+
45+
46+
47+
48+
49+
50+

0 commit comments

Comments
 (0)