Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Computer Performance Engineering 10th European Workshop Epew 2013 Venice Italy September 17 2013 Proceedings

Authors: Maria Simonetta Balsamo ,William Knottenbelt ,Andrea Marin

2013 Edition

3642407242, 978-3642407246

More Books

Students also viewed these Programming questions

Question

How do you ensure data quality?

Answered: 1 week ago