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

Commit b66907a

Browse files
committed
DOCS Added documentation to functions and other refactoring
1 parent 842ee36 commit b66907a

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

‎main.py‎

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,36 @@
1+
# ---------------------------------------------------------------------------------------------------------
2+
3+
14
def is_between_zero_and_one(x: float, y: float) -> bool:
5+
"""Return true if the floats x and y exist between 0 and 1 else otherwise"""
26
return (0 < x < 1) and (0 < y < 1)
37

48

9+
# ---------------------------------------------------------------------------------------------------------
10+
11+
512
def to_binary_string(n: int) -> str:
13+
"""Return a string representing the binary form of an integer"""
614
if n == 1:
715
return "1"
816

917
return to_binary_string(n // 2) + str(n % 2)
1018

1119

20+
# ---------------------------------------------------------------------------------------------------------
21+
22+
1223
def main():
24+
"""For testing"""
1325
test_x: float = 0.1
1426
test_y: float = 0.5
1527

1628
print(is_between_zero_and_one(test_x, test_y))
1729
print(to_binary_string(8))
1830

1931

32+
# ---------------------------------------------------------------------------------------------------------
33+
34+
2035
if __name__ == "__main__":
2136
main()

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /