diff_21

Get an integer from the user. Output the absolute difference between the integer and 21, except output double the absolute difference if the integer is greater than 21. Use the abs() function to get the absolute value. For a greater challenge, you can find the absolute value using if statements.

This exercise was taken from codingbat.com and has been adapted for the Python language. There are many great programming exercises there, but the majority are created for Java.

Test 1

Input:

19

Output:

2

Test 2

Input:

10

Output:

11

Test 3

Input:

21

Output:

0

Test 4

Input:

22

Output:

2

Test 5

Input:

25

Output:

8

Test 6

Input:

30

Output:

18

Test 7

Input:

0

Output:

21

Test 8

Input:

1

Output:

20

Test 9

Input:

2

Output:

19

Test 10

Input:

-1

Output:

22

Test 11

Input:

-2

Output:

23

Test 12

Input:

50

Output:

58