daily pastebin goal
0%
SHARE
TWEET

Python zip/list comprehension explanation

SebastianLague Jun 14th, 2018 (edited) 155 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. #Python
  2. numbers = [4,5,6,7]
  3. powers = [0,1,2,3]
  4. results = [a**b for a,b in zip(numbers,powers)]
  5.  
  6. #C
  7. int[] numbers = {4,5,6,7};
  8. int[] powers = {0,1,2,3};
  9. int[] results = new int[numbers.Length];
  10.  
  11. for (int i = 0; i < numbers.Length; i ++) {
  12.     results[i] = (int)System.Math.Pow(numbers[i], powers[i]);
  13. }
  14.  
  15. #results = 1, 5, 36, 343
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top