Computer Science, asked by noanderson20, 10 months ago

2.4 Code Practice: Question 2 for edhesive

computer science
need answers

Answers

Answered by eburcham58
71

Answer:

import math

x = float(input("Input a decimal number of your choice: "))

y=int(x)

x=x-y

print(math.fabs(x))

Explanation:There you go

Answered by mad210219
9

Code Practice: Question 2 for edhesive

Explanation:

import math

x = float(input("Input a decimal number "))

y=int(x) # converting float to int

x=x-y #subtracting integer number from float number

print(math.fabs(x))

Output:

Input a decimal number 33.39

0.00000000000039 is the answer  

Explaining,

Input=33.39

Int(33.39)=33

So,33.39-33=0.39

Fabs(0.39)=0.0000000000039

fabs(): fabs() is function in math module which gives the absolute value of any value or expression passing to it

for example:

fabs(-11) gives 11.0

fabs(11) gives 11.0

Similar questions