[Tutor] Fwd: Puzzle - Next Step to our interviewing process - Pramati Technologies!

brian arb brianjamesarb at gmail.com
Wed Apr 23 19:47:12 CEST 2014


>>>  nums1 = [3, 1, 4]
>>> nums2 = [2, 7, 1]
>>> [ sum(i) for i in zip(nums1, nums2)]
[5, 8, 5]



On Wed, Apr 23, 2014 at 1:12 PM, Danny Yoo <dyoo at hashcollision.org> wrote:

> Hi Sunil,
>
>
> Try a simpler but related problem first.
>
> Say that you have two lists of numbers, like:
>
> ######
> nums1 = [3, 1, 4]
> nums2 = [2, 7, 1]
> ######
>
> Can you design a function addLists() that takes two lists of numbers
> of equal length, and adds them together?  For example,
>
>     addLists(nums1, nums2) == [5, 8, 5]
>
> should be true, as well as:
>
>      addLists([4, 6], [8, 5]) == [12, 11]
>
>
> Would you be able to write the addLists() function?  Would you be able
> to write a few test cases to check that the implementation works on
> those examples?
> _______________________________________________
> Tutor maillist  -  Tutor at python.org
> To unsubscribe or change subscription options:
> https://mail.python.org/mailman/listinfo/tutor
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/tutor/attachments/20140423/182f14e1/attachment-0001.html>


More information about the Tutor mailing list