Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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 (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
Step: 1
Explanation i printhalfnumbers code def printhalfnumbers for ...Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started