vendredi 23 décembre 2016

can someone pls to help me solve this Data Structure python test

How do i solve this test .


Write a function called manipulate_data which will act as follows:

When given a list of integers, return a list, where the first element is the count of positives numbers and the second element is the sum of negative numbers.

NB: Treat 0 as positive.

Test :

import unittest

class ManipulateDataTestCases(unittest.TestCase): def test_only_lists_allowed(self): result = manipulate_data({}) self.assertEqual(result, 'Only lists allowed', msg='Invalid argument')

def test_it_returns_correct_output_with_positives(self): result = manipulate_data([1, 2, 3, 4]) self.assertEqual(result, [4, 0], msg='Invalid output')

def test_returns_correct_ouptut_with_negatives(self): result = manipulate_data([1, -9, 2, 3, 4, -5]); self.assertEqual(result, [4, -14], msg='Invalid output')

Aucun commentaire:

Enregistrer un commentaire