Question
Hi there! Read carefully please****: The first 2 pictures are the main question and the 3rd pictures is a3q2_provided.py file. The last 3 pictures
Hi there! Read carefully please****:
The first 2 pictures are the main question and the 3rd pictures is " a3q2_provided.py" file. The last 3 pictures are triangle1.txt, triangle2.txt, and triangle3.txt file respectively.
Please give me the full hand written answer of this question and a picture of your code. And make sure to answer all of its parts.
Please Solve it only if you're sure that your answer is 100% correct otherwise let any other person to solve it.
I need the Correct answer please otherwise I'll give dislike and report it to the Chegg authorities. Sorry for these words but I'm tired of getting lots of wrong answers lately.
Please answer it as soon as possible with clear hand writting and and picture of your code. Thank you so much for your time and effort! Will give Thumbs-up if everything is Alright!
Question 2 ( 28 points): Purpose: To practice writing doc-strings. To practice thinking about test-case design Degree of Difficulty: Easy. Restrictions: This question is homework assigned to students and will be graded. This question shall not be distributed to any person except by the instructors of CMPT 145 . Solutions will be made available to students registered in CMPT 145 after the due date. There is no educational or pedagogical reason for tutors or experts outside the CMPT 145 instructional team to provide solutions to this question to a student registered in the course. Students who solicit such solutions are committing an act of Academic Misconduct, according to the University of Saskatchewan Policy on Academic Misconduct The file a3q2. py contains four functions, most of which are correct (but some may not be), In this question. you will be guided in the preparation of a test script to test the functions. - neutonraphson () This function implements a well-known algorithm for computing the square root of a non-negative number. 1. Study the function. and write an appropriate doc-string for it. 2. Design test cases for this function. There are 2 equivalence classes that are of interest. - Numbers between 0 and 1 The square root is bigger than the input number - Numbers greater than 1 . The square root is smaller than the input number - There are two boundary cases 0 , and 1 Write test cases for function, considenng the information above Don't just test integers! - gcd(). This function implements a well-known algorithm for computing the greatest common divisor of two integers. For example. gcil(27, 6) 3. since 3 is the largest integer that evenly divides 27 and 6 . 1 Study the function, and write an appropriate doc-string for it. 2 Notice that the function prints to the console lt's a terrible design decision, it's nearly impossible to test console output from within Python Before you test the function, modify the function to return the value instead. 3. Design test cases for this function. There are several equivalence classes of interest: a>b b>a a=b - What happens when a - 1 or 6 - 1 ? Is this okay? You may need to do some research to figure this out Write test cases for function, considering the information above. readtriangle(). This function opens a named file and reads the contents An exampte of the kind of file that it reads is given, named triangle1. ixt. Notice that the first line in the file is Lhe length of the example. 1 Study the function. and write an appropriate doc-string for it 2 Create a test script for this function Testing a function tike this is difficult because you dont want to type in correct result in your lest script it is hard to do lest functions that read from a fite completety. So here is a strategy that will help - The function reads "Pascal Triangles" Create a coupte more example fites for testing Smaller examples are fine! - Test that the returned size is correct for the example fites - Test that the tength of the retumed triangle is correct - Test that the elements of the triangle are also lists. To check if al ist. refers to a list, you can use the Python code type(alist.) is 1 ist - this is a Boolean expression that returns True if alist was constructed by the list constructor. It will be true for lists, and false for everything else. - remdup(). This function removes duplicates from a given list keeping only the first occurrence of any duplicated value. For example, given the list [1,2,3,1]. remdup () will remove the second occurrence of 1 1. Study the function, and write an appropriate doc-string for it. 2. Create a test scripl while considering the following equivalence classes: - No duplicates - One duplicated item. - One duplicated item. with duplicales appearing sequentially - Multiple duplicated items appearing anywhere in the ust - The only boundary case is the empty list. What to Hand In - A Python script named a3q2_nr.py with your test script for newt tonraphson(). - A Python script named a3q2_ged.py with your test seript for ged(). - A Python script named a3q2_tri.py with your test script for readtriangle() - Apython seript named a3q2_dup.py with your test seript for remdup () - A Python script named a3q2. py with the functions You ve added doc-strings. and modified gcd() as indicated. Be sure to include your name. NSID. student number. section number. and Laboratory section at the top of all documents. Evaluation - Function interface documentation. You added the doc-stings giving the correct information - 2 marks for each function. - Your test seripts perform the indicated lesting - 5 marks for each function. Marks will be deducted if - the testing does not include sufficient lest cases some of the equivatence classes are not lesled the test script is overly convoluted or otherwise demonstrates poor style or design 7111111112345613610151410201515161 5111111234136141 2111Step by Step Solution
There are 3 Steps involved in it
Step: 1
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