Question: For each of the following Python functions, write their code complexity in big O notation. i) def print_half (numbers): Print half of the numbers

For each of the following Python functions, write their code complexity in big O notation. i) def print_half iii) def add_numbers (n): end_number = 2 ** n iv) def v) def count = 0 for i in range(0, end_number): count b) Consider the following Python list of items: numbers = [ 9, 84, 12, 3, 25, 34, 31, 65, 53 ] i) Using list contents of scores.csv vick, 83.2 siti,78.1 zen, 57 lucas, umbras, 77.7 66 fred, 35.8 stan, 93.2 lily, 37.7

For each of the following Python functions, write their code complexity in big O notation. i) def print_half (numbers): """Print half of the numbers (added by 1). """ for i in range(0, len (numbers)//2 + 1): number = numbers [i] + 1 print (number) ii) def print_something (num): """Print recursively. if num iii) def add_numbers (n): end_number = 2 ** n iv) def v) def count = 0 for i in range(0, end_number): count += i return count get_first_last (array): return array[0], array[len(array) - 1] print_times_table(n): for i in range (1, n+1): for j in range(1, 13): print (f"{i*j:3}", end="") print() b) Consider the following Python list of items: numbers = [ 9, 84, 12, 3, 25, 34, 31, 65, 53 ] i) Using list comprehensions, write code to obtain the following: [81, 7056, 144, 9, 625, 1156, 961, 4225, 2809] # squares of each numbers 3 # count of numbers that are even. [5] ii) Write the load_scores() function to read a file with the following scores.csv into a list of floats. Write another function get_average() to calculate the average score. When the codes below are run, the output should show the following: [10] scores load_scores ("scores.csv") average_score= get_average (scores) print (f"Average score is (average_score:.1f}") contents of scores.csv vick, 83.2 siti,78.1 zen, 57 lucas, umbras, 77.7 66 fred, 35.8 stan, 93.2 lily, 37.7 Output: Average score is 66.1

Step by Step Solution

3.32 Rating (152 Votes )

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock

Detailed Analysis and Solutions Part A Code Complexity in Big O Notation i printhalfnumbers Logic It... View full answer

blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Programming Questions!