Skip to content

Commit 2fd3693

Browse files
📝 Add docstrings to add-utils
Docstrings generation was requested by @HammerHam. * #72 (comment) The following files were modified: * `simple_utils.py`
1 parent ef04b8d commit 2fd3693

File tree

1 file changed

+37
-0
lines changed

1 file changed

+37
-0
lines changed

simple_utils.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,37 @@
1+
# simple_utils.py - A tiny utility library
2+
3+
def reverse_string(text):
4+
"""
5+
Return a new string with the characters of the input string in reverse order.
6+
7+
Parameters:
8+
text (str): The string to be reversed.
9+
10+
Returns:
11+
str: The reversed string.
12+
"""
13+
return text[::-1]
14+
15+
def count_words(sentence):
16+
"""
17+
Count the number of words in a sentence by splitting on whitespace.
18+
19+
Parameters:
20+
sentence (str): The input string to analyze.
21+
22+
Returns:
23+
int: The number of words found in the sentence.
24+
"""
25+
return len(sentence.split())
26+
27+
def celsius_to_fahrenheit(celsius):
28+
"""
29+
Convert a temperature from Celsius to Fahrenheit.
30+
31+
Parameters:
32+
celsius (float): Temperature value in degrees Celsius.
33+
34+
Returns:
35+
float: Equivalent temperature in degrees Fahrenheit.
36+
"""
37+
return (celsius * 9/5) + 32

0 commit comments

Comments
 (0)