Advertisement
akosiraff

3 Python Functions

Feb 1st, 2019
194
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.15 KB | None | 0 0
  1.  
  2. Download: https://solutionzip.com/downloads/3-python-functions/
  3. Exercise 1:
  4. Create a function that accepts a single array as an argument. Given an array of integers, x, sort x and split the integers into three smaller arrays of equal length. If the length of x is not evenly divisible by three, increase the size of the smaller arrays by one starting from the first array. The function should return an array of arrays. Example: Input = [2,1,3,4,7,5,9,6,8,13,12,11,10,0,15,16,14] Output = [ [0, 1, 2, 3, 4, 5], [6, 7, 8, 9, 10, 11], [12, 13, 14, 15, 16] ]
  5. Exercise 2:
  6. Write a function that find the frequency occurrence of a letter in a sentence. The function should return an integer. (Do not use the str.count() default python function) Examples: find_frequency(“t”, “this is a test”) ? 3 find_frequency(“y”, “this is a test”) ? 0
  7. Exercise 3:
  8. Write a function that identifies if an integer is a power of 2. The function should return a boolean. Explain why your function will work for any integer inputs that it receives. Examples: is_power_two(6) ? false is_power_two(16) ? true
  9.  
  10. Download: https://solutionzip.com/downloads/3-python-functions/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement