Need help on a project To :"Create a class called BankAccount with the following parameters "

Joel Goldstick joel.goldstick at gmail.com
Wed Dec 30 15:11:27 EST 2015


On Wed, Dec 30, 2015 at 3:06 PM, Joel Goldstick <joel.goldstick at gmail.com>
wrote:

>
>
> On Wed, Dec 30, 2015 at 1:21 PM, Won Chang <princeudo52 at gmail.com> wrote:
>
>>
>> i have these task which i believe i have done well to some level
>>
>> Create a function get_algorithm_result to implement the algorithm below
>>
>> 1- Get a list of numbers L1, L2, L3....LN as argument 2- Assume L1 is the
>> largest, Largest = L1 3- Take next number Li from the list and do the
>> following 4- If Largest is less than Li 5- Largest = Li 6- If Li is last
>> number from the list then 7- return Largest and come out 8- Else repeat
>> same process starting from step 3
>>
>> Create a function prime_number that does the following Takes as parameter
>> an integer and Returns boolean value true if the value is prime or Returns
>> boolean value false if the value is not prime
>>
>> so i came up with this code below
>>
>> def get_algorithm_result(my_list):
>> if not any(not type(y) is int for y in my_list):
>>
>
Not sure what above line is trying to do? Check that item is int?  That
won't help with the case of strings in my_list

>     largest = 0
>>     for item in range(0,len(my_list)):
>>
>
The above line can be more pythonically expressed as
           for item in my_list:
                if largest < item:
                   largest = item
           return largest

Then below is gone.  Not sure what the else clause below is for

>         if largest < my_list[item]:
>>             largest = my_list[item]
>>     return largest
>> else:
>>
>>     return(my_list[-1])
>>
>> def prime_number(integer):
>> if integer%2==0 and 2!=integer:
>>     return False
>> else:
>>     return True
>>
>> get_algorithm_result([1, 78, 34, 12, 10, 3])
>> get_algorithm_result(["apples", "oranges", "mangoes", "banana", "zoo"])
>> prime_number(1)
>> prime_number(78)
>> prime_number(11)
>> for the question above, there is a unittes which reads
>>
>> import unittest
>>
>> class AlgorithmTestCases(unittest.TestCase):
>>   def test_maximum_number_one(self):
>>     result = get_algorithm_result([1, 78, 34, 12, 10, 3])
>>     self.assertEqual(result, 78, msg="Incorrect number")
>>
>>   def test_maximum_number_two(self):
>>     result = get_algorithm_result(["apples", "oranges", "mangoes",
>> "banana", "zoo"])
>> self.assertEqual(result, "zoo", msg="Incorrect number")
>>
>>   def test_prime_number_one(self):
>>     result = prime_number(1)
>>     self.assertEqual(result, True, msg="Result is invalid")
>>
>>   def test_prime_number_two(self):
>>     result = prime_number(78)
>>     self.assertEqual(result, False, msg="Result is invalid")
>>
>>   def test_prime_number_three(self):
>>     result = prime_number(11)
>>     self.assertEqual(result, True, msg="Result is invalid")
>> but once i run my code ,it returns error saying Test Spec Failed
>>
>> Your solution failed to pass all the tests
>> what is actually wrong with my code?
>>
>
> You need to copy and paste the complete results and or traceback.  There
> is no string "Test Spec Failed" in anything you have shown
>
>> --
>> https://mail.python.org/mailman/listinfo/python-list
>>
>
>
>
> --
> Joel Goldstick
> http://joelgoldstick.com/stats/birthdays
>



-- 
Joel Goldstick
http://joelgoldstick.com/stats/birthdays



More information about the Python-list mailing list