File tree Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Expand file tree Collapse file tree 1 file changed +27
-1
lines changed Original file line number Diff line number Diff line change 11# simple_utils.py - A tiny utility library
22
33def 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
715def 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
1027def 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
You can’t perform that action at this time.
0 commit comments