Skip to main content

Foundations of Python Programming: Functions First

Section 4.14 Chapter Assessment

Checkpoint 4.14.1.

Write a function called int_return that takes an integer as input and returns the same integer.

Checkpoint 4.14.2.

Write a function called add that takes any number as its input and returns that sum with 2 added.

Checkpoint 4.14.3.

Write a function called change that takes any string, adds “Nice to meet you!” to the end of the argument given, and returns that new string.

Checkpoint 4.14.4.

Write a function, addup, that takes five integers as inputs and returns the sum of those integers.

Checkpoint 4.14.5.

You will need to write two functions for this problem. The first function, divide that takes in any number and returns that same number divided by 2. The second function called sum should take any number, divide it by 2, and add 6. It should return this new number. You should call the divide function within the sum function. Do not worry about decimals.

Checkpoint 4.14.6.

You will need to write three functions for this problem.
  • The first function, average that takes in any three numbers and returns the average.
  • The second function called diffSquare that takes one number and the average of the three numbers, subtracts those numbers, and then returns the square of this difference.
  • A third function called stdev which is passed the three numbers and then:
    1. Calls on average to find the averaage of those three values, and assign the resulting average to a local variable.
    2. Calls on diffSquare three times, passing each of the three numbers in turn and the local variable average, assigning the resulting squared differences to three local variables.
    3. Calls on average again, this time passing in the three squared differences, and assigning this new average to a variable called variance.
  • Finally, stdev finds the square root of variance as the standard deviation
Do not worry about rounding the decimals.
You have attempted of activities on this page.