Homework on Functions - Questions

  1. Describe what a function does in your own words
    A function is a command which execute a given input to result in an output.

  2. Calculate the output of the following function

f(x) = {

x^2 if x is even

x+10 if x is odd

}

What will be the output for the following inputs?

  • a) f(2) = 4

  • b) f(7) = 17

  • c) f(0) = 0

  1. Write the definition of a function f that takes an input x, divides it by four and then outputs that result subtracted by 5.

f(x) = x/4-5

1 Like

This is not correct, you must subtract 5. :slight_smile:

1 varible is inserted and result is the computation of the formula
a 4
b 70
c 0
f(x)/4-5

1 Like
  1. Describe what a function does in your own words
  • Functions are used in order to define conditions that will satisfy an equation as it requires an input and an output
  1. Calculate the output of the following function
f(x) = {

x^2 if x is even

x+10 if x is odd

}

What will be the output for the following inputs?

  • a) f(2)=4
  • b) f(7) = 17
  • c) f(0)= 0
  1. Write the definition of a function f that takes an input x, divides it by four and then outputs that result subtracted by 5.
  • f(x)=x/4-5
1 Like
  1. Function is basically a mathematical instruction which takes in input and gives output
  2. f(2) = 4, f(7) = 17, f(0) = 0;
  3. f(x) = (x/4)- 5
1 Like

a. 4
b 17
c 0

  1. f(x) = {x/4}
    f-5 = {}
    f(x)=(x/4)-5
1 Like
  1. A function is a mathematical equation where an imput value performs a specified duty to create an output value

  2. f(2)=4, f(7)=17, f(0)=0

  3. f(x)=(x/4) -5

1 Like

Ok thanks. It seemed to suggest that the result should be subtracted BY five, which I read as five subtracting the result.

Yup, thank you for paying attention.

  1. Describe what a function does in your own words

With a function there is an input and then an output.

  1. Calculate the output of the following function
f(x) = {

x^2 if x is even

x+10 if x is odd

}

What will be the output for the following inputs?

  • a) f(2) = 4
  • b) f(7) = 17
  • c) f(0) = 0
  1. Write the definition of a function f that takes an input x, divides it by four and then outputs that result subtracted by 5.

f(x) = (x/4)-5

1 Like
  1. A function is a set of instructions to get an output as a result.
    2a = 4 ( 2 is even: 2**2 = 4)
    2b = 17 ( 7 is odd: 7+10 = 17)
    2c = 0 ( is just 0)
  2. f(x) = (x/4) - 5

I have been learning basic python for a while so I made this to do the homework
don’t mind my newbie Python powers :stuck_out_tongue:

print(‘Program will make your homework easier!’)
number = float(input(‘Enter a number: ‘))
if (number % 2) == 0:
newNumber = number ** 2
print(str(number)+’ is even: f(x) = x**2’)
print(str(number)+’ **2 = ‘+str(newNumber))
else:
newNumber = number + 10
print(str(number)+’ is odd: f(x) = x+10’)
print(str(number)+’ +10 = '+str(newNumber))

can someone tell me why the text editor is not respecting the white spaces on my little code here? :open_mouth:

1 Like

Function is an action of mathematical calculation that has an input, calculates and then brings the output.
a. 4
b. 17
c. 0
f(x) = (x/4)-5

1 Like

You should add 10, not multiply by it. :slight_smile:

1 Like

You should use a code block to format code. You wrap it in three ` at the start and end:

// This is a code block initialized with ```
some
  formated
    code
// This is the end of the code block ```
1 Like
  1. A function provides a computation that gives an output from the input you gave the function.

a) 4
b) 17
c) 0

  1. f(x) = (x/4) -5
1 Like

A function is an equation that has an input and an output.

4
17
0

1 Like
  1. A function can be thought of as a formula used to get a desired output with a variable input.

a) 4
b) 17
c) 0
2. f(x) =(x/4)-5

1 Like

1.Describe what a function does in your own words:
-The computation takes an input and computes a output

  • a) f(2) = 4
  • b) f(7) = 17
  • c) f(0) = 0

3.f(x)=(X/4)-5

1 Like

question number 3???

  1. a function will compute the output if you give it input for the variable.it will always do the same no matter what variable you put in.

  2. f(2) = 2^2 = 4 (even)
    f(7) = 7+10= 17 (odd)
    f(0) = 0^2 = 0. (even)

  3. f(x) = x/4-5

1 Like