SHARE
SPREAD
HELP

The Tradition of Sharing

Help your friends and juniors by posting answers to the questions that you know. Also post questions that are not available.


To start with, Sr2Jr’s first step is to reduce the expenses related to education. To achieve this goal Sr2Jr organized the textbook’s question and answers. Sr2Jr is community based and need your support to fill the question and answers. The question and answers posted will be available free of cost to all.

 

#
Authors:
Tony Gaddis
Chapter:
Value Returning Functions And Modules
Exercise:
Algorithm Workbench
Question:2 | ISBN:9780132576376 | Edition: 2

Question

The following statement calls a function named half, which returns a value that is half that of the argument. (Assume the number variable references a float value.) Write
code for the function. 
result = half(number)

TextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbookTextbook

Answer

The following python code statement calls a function named 'half', which returns a value that is half that of the argument is as follows:

def half(number):
    return number / 2

Explanation:

  • A function with the name "half" that takes a number as an argument.
  • The capability separates number by 2 and returns the outcome. Half of the original number will be returned when you call half(number).
0 0

Discussions

Post the discussion to improve the above solution.