521,264 views
32 votes
32 votes
Write a template that accepts an argument and returns its absolute value. The absolute entered by the user, then return the total. The argument sent into the function should be the number of values the function is to read. Test the template in a simple driver program that sends values of various types as arguments and displays the results.

User Maslak
by
2.7k points

1 Answer

10 votes
10 votes

Answer:

In python:

The template/function is as follows:

def absval(value):

return abs(value)

Step-by-step explanation:

This defines the function

def absval(value):

This returns the absolute value of the argument using the abs() function

return abs(value)

To call the function from main, you may use:

print(absval(-4))

User Creative Crypter
by
3.3k points