Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

I did not do well on the following assignment, please kindly share the solutions with explanations so that I may rectify the same mistakes in

I did not do well on the following assignment, please kindly share the solutions with explanations so that I may rectify the same mistakes in the future, the marking rubric is attached.

Marking Rubric:

image text in transcribedimage text in transcribed
the function signature matches the description given (has the name and arguments EXACTLY as specified) the function has the expected behaviour and for code quality according to software engineering properties such as: documentation in docstring format: type hints, purpose, examples readability use of whitespace o splitting complex computation or long statements across multiple lines meaningful variable names o lower case, starting with an alpha-character proper use of constants (avoid magic numbers) defined above all function definitions o in UPPERCASE use of code constructs (functions, variables, conditions) to: o eliminate redundant code and redundant computation testing coverage O you have added an example in your docstring to cover each boundary case within your program NOTE: examples given in the function specification do not necessarily cover all boundary case often you will have to create additional examples.You cannot use list comprehensions to solve any of these problems. If you don't know what these are, don't worry about it, you don't need to know about them for this course. 1. Design the function sum_even_values that takes a list of integers as an argument and calculates the sum of only the values in the list that are even. Don't forget to add a test for the empty list! Examples: If the function is called with the list [12, 4, 3, -2] the function should return 14 since 12 + 4 + -2 = 14 2. Design the function count_above that takes a list of numbers and a threshold value as arguments and counts the number of values in the list that are above the given threshold. Don't forget to add tests that consider the empty list and around the threshold boundary (below, at, above)! Tip for your type hint... if a function accepts an argument that is a integer or a float, what type hint is used? Examples: If the function is called with the list [12, 4, 2, 22, -4] and a threshold of 2 the function should return 3 If the function is called with the list [1.2, 2.4, 2.7] and a threshold of 2.1 the function should return 2 3. Design the function addl that takes a list of integers as an argument and creates and returns a new list with every value in the given list with 1 added to it. Don't forget to add a test for the empty list! Examples: If the function is called with the list [12, 4, 3, -2] the function should return the list [13, 5, 4, -1] The list passed as an argument should not be changed! 4. Design the function are_all_even that takes a list of integers and determines whether all of the elements in the list are even. Don't forget to add a test for the empty list - if the list is empty there are not any odd numbers so the function should return True (they are all even). Examples: If the function is called with the list [12, 4, 3, -2] the function should return False If the function is called with the list [12, 4, 30, -2] the function should return True

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image

Step: 3

blur-text-image

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Financial management theory and practice

Authors: Eugene F. Brigham and Michael C. Ehrhardt

12th Edition

978-0030243998, 30243998, 324422695, 978-0324422696

Students also viewed these Programming questions

Question

Name the three phases of cardiac cycle in the order form.....?

Answered: 1 week ago

Question

Define psychology and it's school of thoughts in short ?

Answered: 1 week ago

Question

What is the most effective way to stop a nose bleed ?

Answered: 1 week ago

Question

The patients blood pressure is 180/105 is hyper tension?

Answered: 1 week ago