Computer Science, asked by rajesh70445, 9 months ago

write a python program to get the difference between a given number and 17, if the number greater than 17 return double the absolute difference.​

Answers

Answered by eswarmanikanta7799
2

Answer:

def num_diff():

a = int(input('Please enter a number:'))

d = a -17

if a>17:

s=2*d

return s

else:

return d

Answered by SaurabhJacob
2

The python program is,

a=float(input("Enter the number = "))

if (a-17)>17:

   print(2*abs(a-17))

The python program above is taking an input of float type into the variable 'a'.

After that, the condition is being checked by the if statement according to the given question. And, printing the double of the absolute difference.

  • abs(input)

It is a function that returns the absolute value for the given input. It converts negative numbers to positive numbers and keeps the positive number as it is.

Similar questions