We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 21aa9c4 commit 6ddfbe6Copy full SHA for 6ddfbe6
maths/decimal_isolate.py
@@ -0,0 +1,25 @@
1
+"""
2
+Isolate the Decimal part of a Number
3
4
+
5
6
+def decimal_isolate(number, digitAmount):
7
8
+ """
9
+ Isolates the decimal part of a number.
10
+ If digitAmount > 0 round to that decimal place, else print the entire decimal.
11
+ >>> decimal_isolate(35.345, 1)
12
+ 0.3
13
+ >>> decimal_isolate(35.345, 2)
14
+ 0.34
15
+ >>> decimal_isolate(35.345, 3)
16
+ 0.345"""
17
+ if digitAmount > 0:
18
+ return round(number - int(number), digitAmount)
19
+ return number - int(number)
20
21
22
+if __name__ == "__main__":
23
+ print(decimal_isolate(35.345, 1))
24
+ print(decimal_isolate(35.345, 2))
25
+ print(decimal_isolate(35.345, 3))
0 commit comments