|
| 1 | +# --------------------------------------------------------------------------------------------------------- |
| 2 | + |
| 3 | + |
1 | 4 | 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""" |
2 | 6 | return (0 < x < 1) and (0 < y < 1)
|
3 | 7 |
|
4 | 8 |
|
| 9 | +# --------------------------------------------------------------------------------------------------------- |
| 10 | + |
| 11 | + |
5 | 12 | def to_binary_string(n: int) -> str:
|
| 13 | + """Return a string representing the binary form of an integer""" |
6 | 14 | if n == 1:
|
7 | 15 | return "1"
|
8 | 16 |
|
9 | 17 | return to_binary_string(n // 2) + str(n % 2)
|
10 | 18 |
|
11 | 19 |
|
| 20 | +# --------------------------------------------------------------------------------------------------------- |
| 21 | + |
| 22 | + |
12 | 23 | def main():
|
| 24 | + """For testing""" |
13 | 25 | test_x: float = 0.1
|
14 | 26 | test_y: float = 0.5
|
15 | 27 |
|
16 | 28 | print(is_between_zero_and_one(test_x, test_y))
|
17 | 29 | print(to_binary_string(8))
|
18 | 30 |
|
19 | 31 |
|
| 32 | +# --------------------------------------------------------------------------------------------------------- |
| 33 | + |
| 34 | + |
20 | 35 | if __name__ == "__main__":
|
21 | 36 | main()
|
0 commit comments