Advertisement
Guest User

Untitled

a guest
Oct 19th, 2019
102
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.74 KB | None | 0 0
  1. import unittest
  2.  
  3. numbers = [1, 2, 3, 4]
  4.  
  5. # Task 1 - Create a new list, calculating the square number (x * x) for each item in the list
  6. # Expected output:
  7. # [1, 4, 9, 16]
  8.  
  9.  
  10. # Task 2 - Filter all the even numbers in the list
  11. # Expected output: [2, 4]
  12.  
  13.  
  14. # Task 3 - Sum all the odd numbers in the list
  15. # Expected output: 4
  16.  
  17. print("Hello!")
  18.  
  19. #1
  20. def foo(lst):
  21. rs = [x*x for x in lst]
  22. return rs
  23.  
  24.  
  25.  
  26. def test_foo_params_success(lst):
  27. assert isinstance(lst, list) == True
  28.  
  29. def test_foo_params_failure(lst):
  30. assert isinstance(lst, list) == False
  31.  
  32. def test_squre(lst):
  33. rs = foo(lst)
  34. for index, obj in enumarate(lst):
  35. assert (obj*obj, rs[index]), True
  36.  
  37.  
  38. test_foo_params_success([1,2,3,4])
  39.  
  40. print("Completed!")
  41.  
  42. test_foo_params_failure('sd')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement