Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit2fd3693

Browse files
📝 Add docstrings toadd-utils
Docstrings generation was requested by@HammerHam.*#72 (comment)The following files were modified:* `simple_utils.py`
1 parentef04b8d commit2fd3693

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+
defreverse_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+
returntext[::-1]
14+
15+
defcount_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+
returnlen(sentence.split())
26+
27+
defcelsius_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)

[8]ページ先頭

©2009-2025 Movatter.jp