def test_e_function_subtract_output(self): """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments - function subtract_numbers() subtracts correctly""" # Try to import before testing try: import lab3b as lab3bStudent except: self.fail( 'lab3b.py contains errors(HINT: run the function and fix errors' ) error_output = 'problem subtracting(HINT: subtract_numbers(10, 5)' self.assertEqual(str(lab3bStudent.subtract_numbers(10, 5)), '5', msg=error_output)
def test_b_function_subtract(self): """[Lab 3] - [Investigation 2] - [Part 1] - functions & arguments - function subtract_numbers() fails without 2 arguments""" with self.assertRaises(Exception) as context: import lab3b as lab3bStudent lab3bStudent.subtract_numbers()
#!/usr/bin/env python3 '''Lab 3 Part 1 script - functions''' # Author ID: rkhan2 def sum_numbers(number1, number2): # Make this function add number1 and number2 and return the value return number1 + number2 def subtract_numbers(number1, number2): # Make this function subtract number1 and number2 and return the value # Remember to make sure the function accepts 2 arguments return number1 - number2 def multiply_numbers(number1, number2): # Make this function multiply number1 and number2 and return the value # Remember to make sure the function accepts 2 arguments return number1 * number2 import lab3b if __name__ == '__main__': print(str(lab3b.sum_numbers(10, 5))) add = lab3b.sum_numbers print(str(lab3b.subtract_numbers(10, 5))) print(str(lab3b.multiply_numbers(10, 5)))