Question
Program 25: The absolute value of 1 is 1, and the absolute value of -1 is also 1. Write a function that calculates the absolute
Program 25: The absolute value of 1 is 1, and the absolute value of -1 is also 1. Write a function that calculates the absolute value and returns the absolute value of a number. Call the function and show how your program ran. Do not just use the built-in python function abs()! You must write the definition yourself! Be sure to type the function name and the function calls below, copy/pasting it will give you errors! Function name: def absolute(a) Function call: print ( 'The absolute value of -1 is', absolute(-1) ) print ( 'The absolute value of 1 is', absolute(1) ) Function test runs: The absolute value of -1 is 1 The absolute value of 1 is 1 Example of how to find an absolute value: # Be sure to type the example below, copy/pasting it will give you errors! # The variable 'a' below will be the function parameter. # The code below must be in a function! a = float (input ("Enter a positive or negative value:)) if a >= 0: print (absolute value is:', a) if a < 0: a = a*(-1) print (absolute value of', a, 'is:', a*(-1)) Save and submit it as p25.py
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started