3 Python Functions

Ratings: 1 Star2 Stars3 Stars4 Stars5 Stars (5.00 out of 5) - Rate Now!

Download Category:

3 Python Functions.zip - (76.12 KB)
3 Python Functions/exercises.py
3 Python Functions/Question.txt
3 Python Functions/Screenshot_1.png

Exercise 1:
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] ]

Exercise 2:
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

Exercise 3:
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

Get a fresh solution of this question. Ask it now to our experts.

Ask Your Question

We have verified professionals who are ready to answer your question.


Save Time and Money

We choose experts who can quickly answer your question and that suit your budget.


Get Your Answer

Your satisfaction is 100% guaranteed. You can keep on asking questions until you get the answer you need.