Skip to content
This repository was archived by the owner on Apr 24, 2025. It is now read-only.

Commit a87366c

Browse files
Merge pull request #746 from yest3a/my-documentation
Added docstrings to some functions
2 parents cddb477 + 4220358 commit a87366c

1 file changed

Lines changed: 18 additions & 0 deletions

File tree

projects/Calculator/main.py

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,13 +56,25 @@ def average():
5656

5757

5858
def factorial(num):
59+
"""
60+
Function to calculate the factorial of a number.
61+
62+
Takes a number as an argument, calculates the factorial of the number,
63+
and returns the result.
64+
"""
5965
answer = 1
6066
for i in range(num):
6167
answer *= i + 1
6268
return answer
6369

6470

6571
def complex_arithmetic():
72+
"""
73+
Function to execute complex arithmetic operations such as addition, subtraction, multiplication, and division.
74+
75+
Asks the user to choose the operation and input the complex numbers as real and imaginary parts,
76+
performs the operation, and returns the result.
77+
"""
6678
print("Enter '1' for complex addition")
6779
print("Enter '2' for complex subtraction")
6880
print("Enter '3' for complex multiplication")
@@ -118,6 +130,12 @@ def complex_arithmetic():
118130

119131

120132
def binomial(num):
133+
"""
134+
Function to calculate the binomial coefficient.
135+
136+
Takes two numbers as arguments, calculates the binomial coefficient using the formula n!/(k!(n-k)!),
137+
and returns the result.
138+
"""
121139
result = factorial(num[0]) / (factorial(num[1]) * factorial(num[0] - num[1]))
122140
return result
123141

0 commit comments

Comments
 (0)