On Friday, January 8, 2016 at 11:38:11 AM UTC-5, acushl...@gmail.com wrote:
> On Wednesday, 30 December 2015 19:21:32 UTC+1, Won Chang  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):
> >     largest = 0
> >     for item in range(0,len(my_list)):
> >         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?
> 
> I had to use a hack to bypass it, worked and I moved on to next quiz

Hello, I have this same assignment to create Bank account and I am new to 
python. please help me out.

Create a class called BankAccount

    Create a constructor that takes in an integer and assigns this to a 
`balance` property.
    Create a method called `deposit` that takes in cash deposit amount and 
updates the balance accordingly.
    Create a method called `withdraw` that takes in cash withdrawal amount and 
updates the balance accordingly. if amount is greater than balance return 
`"invalid transaction"`
    Create a subclass MinimumBalanceAccount of the BankAccount class


import unittest
class AccountBalanceTestCases(unittest.TestCase):
  def setUp(self):
    self.my_account = BankAccount(90)
    
  def test_balance(self):
    self.assertEqual(self.my_account.balance, 90, msg='Account Balance Invalid')
    
  def test_deposit(self):
    self.my_account.deposit(90)
    self.assertEqual(self.my_account.balance, 180, msg='Deposit method 
inaccurate')
    
  def test_withdraw(self):
    self.my_account.withdraw(40)
    self.assertEqual(self.my_account.balance, 50, msg='Withdraw method 
inaccurate')
    
  def test_invalid_operation(self):
    self.assertEqual(self.my_account.withdraw(1000), "invalid transaction", 
msg='Invalid transaction')
  
  def test_sub_class(self):
    self.assertTrue(issubclass(MinimumBalanceAccount, BankAccount), msg='No 
true subclass of BankAccount')
 
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to