Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

To practice testing for functions you write yourself Degree of Difficulty: For each of the following, implement the stated function, and test it: The function

image text in transcribed
To practice testing for functions you write yourself Degree of Difficulty: For each of the following, implement the stated function, and test it: The function closest_to_zero3(num1, num2, num3) returns value closest to zero from its 3 inputs For example, given the numbers 2, 7,0, the number closes to 0 is 0. For another example, number closest to O when comparing 3, -1, 5 is -1. The function more_odds_than_even(num_list) returns True if the sum of all integers from num_list in odd numbered indices is greater than the sum of all integers of even numbered indices For example, the function should return False for the list [1, 2, 3] (Index portions O and 2 give the sum of 4 (1+3), and index position 1 gives the sum of 2) and True for the list [1, 2] (There is only one even index position (0). and one odd index position(1), and 2 > 1) Your testing can be done using the techniques given in the textbook (Chapter 15), or as demonstrated in the Lab 8 A document called a8q3.py containing your functions and testing code as described above You can put your test driver in this document, or you can submit a separate test-driver script named a8q3_testing.py. Be sure to include your name. NSID. student number course number and lecture section and laboratory section at the top of all documents Your function closest_to_zero3() takes 3 input values and the integer closest to 0 correctly. The doc-string for closest_to_zero3() is sufficiently descriptive, indicating its purpose and requirements. You designed test-cases and implemented a test driver that would reveal faults in your closest_to_zero3() Your function more_odds_than_even() takes one list as input and returns a boolean value indicating whether or the sum of integers n oddly numbered index positions is greater than the sum of integers in evenly numbered index positions. The doc-string for more_odds_than_even() is sufficiently descriptive, indicating its purpose and requirements You designed test-cases and implemented a test driver that would reveal faults in your more_odds_than_even()

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

Flash XML Applications Use AS2 And AS3 To Create Photo Galleries Menus And Databases

Authors: Joachim Schnier

1st Edition

0240809173, 978-0240809175

More Books

Students also viewed these Databases questions

Question

What is the basis for Security Concerns in Cloud Computing?

Answered: 1 week ago

Question

Describe the three main Cloud Computing Environments.

Answered: 1 week ago