Skip to content

Commit e43f357

Browse files
📝 Add docstrings to add-utils
Docstrings generation was requested by @npthl2. * #1 (comment) The following files were modified: * `simple_utils.py`
1 parent 4cde465 commit e43f357

File tree

1 file changed

+27
-1
lines changed

1 file changed

+27
-1
lines changed

simple_utils.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,39 @@
11
# simple_utils.py - A tiny utility library
22

33
def reverse_string(text):
4-
"""Reverses the characters in a string."""
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+
"""
513
return text[::-1]
614

715
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+
"""
825
return len(sentence.split())
926

1027
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+
"""
1137
return (celsius * 9/5) + 32
1238

1339

0 commit comments

Comments
 (0)