Programming Examples

Python program to print absolute value of number provided by the user


Program to print absolute value of number provided by the user.

Solution

num=eval(input("Enter a number:"))
print('|',num,'|=',(-num if num<0 else num),sep='')
Output

Enter a number:-9

|-9|=9

Online Exam Quiz for One day Exam Online Typing Test CCC Online Test 2026 Best Computer Training Institute in Prayagraj (Allahabad) Best Java Training Institute in Prayagraj (Allahabad) Best Python Training Institute in Prayagraj (Allahabad) O Level Online Test in Hindi Best Website and Software Company in Allahabad