File tree Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Expand file tree Collapse file tree 1 file changed +37
-0
lines changed Original file line number Diff line number Diff line change 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
You can’t perform that action at this time.
0 commit comments