Week 5 Homework


1. Write a function cubed() that uses the power() function to compute the cube (power of 3) of a number.

2. Write a python script to cube teh values in the input.txt file and save it as cubed.txt

Your code must:

  • Have a function named "cube()"
  • The cubed function must:
    • Take only one parameter, the number to be cubed
    • Return the cubed number
    • Call the comp_power() function (it cannot cube the number on its' own)
  • Open the input file input.txt
  • Loop through each value in the input file
  • Calculate the cube of each number using your function cubed()
  • Save the cubed value to the cubed.txt output file

Please submit your python code as your_name_cubed.py.

Please drop it here:

https://dropitto.me/BIOF309-HW-Week5

I will campare your results to the file name cubed_answers.txt


In [18]:
# Recall that the power function we used in class is:

def comp_power(x, y):
    value = x**y
    return value

In [ ]: