Questions: 5 831

Answers by our Experts: 5 728

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Search & Filtering

"Debugging" lists three possibilities to consider if a function is not working.

  • Describe each possibility in your own words.
  • Define "precondition" and "postcondition" as part of your description.
  • Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.

Debugging lists three possibilities to consider if a function is not working.

  • Describe each possibility in your own words.
  • Define "precondition" and "postcondition" as part of your description.
  • Create your own example of each possibility in Python code. List the code for each example, along with sample output from trying to run it.

List three possibilities to consider if a function is not working.


Section 6.9 of your textbook ("Debugging") lists three possibilities to consider if a function is not working.


Describe each possibility in your own words.



Define "precondition" and "postcondition" as part of your description.


Do Exercise 6.4 from your textbook using recursion and the is_divisible function from Section 6.4. Your program may assume that both arguments to is_power are positive integers. Note that the only positive integer that is a power of "1" is "1" itself.



After writing your is_power function, include the following test cases in your script to exercise the function and print the results:



print("is_power(10, 2) returns: ", is_power(10, 2))


print("is_power(27, 3) returns: ", is_power(27, 3))


print("is_power(1, 1) returns: ", is_power(1, 1))


print("is_power(10, 1) returns: ", is_power(10, 1))


print("is_power(3, 3) returns: ", is_power(3, 3))



You should submit a script file and a plain text output file (.txt) that contains the test output. Multiple file uploads are permitted. Don’t forget to include descriptive comments in your Python code.


Part 2

Invent your own function that does some useful computation of your choosing. Do not copy the function from somewhere else. Use incremental development, and record each stage of the development process as you go. Finally, print output that demonstrates that the function works as you intended.

Include all of the following in your Learning Journal:

  • An explanation of each stage of development, including code and any test input and output.
  • The output of three calls to your function with different arguments.

Section 6.2 of your textbook describes incremental development. Do the exercise at the end of that section:

As an exercise, use incremental development to write a function called hypotenuse that returns the length of the hypotenuse of a right triangle given the lengths of the other two legs as arguments. Record each stage of the development process as you go. (Downey, 2015)

After the final stage of development, print the output of hypotenuse(3, 4) and two other calls to hypotenuse with different arguments.

Include all of the following in your Learning Journal:

  • An explanation of each stage of development, including code and any test input and output.
  • The output of hypotenuse(3,4).
  • The output of two additional calls to hypotenuse with different arguments.





Part 3


Describe your experience so far with peer assessment of Discussion Assignments.


  • How do you feel about the feedback and ratings you have received from your peers?
  • How do you think your peers feel about the feedback you provided them? And the ratings you gave them?

Let’s assume Sheldon Cooper gives his friends the password for entering his

house and only let them enter his house if the password is correct. This

password must contain at least one number. If the password fails to have at

least one number, print “Leave”. Then, Sheldon runs a program that sums the

ASCII values of the numbers which were found from the password.

If the summation is an even number, then the program prints “Correct, you

may enter”.

If the summation is an odd number, then the program prints “Incorrect, you

may leave”.

Write a python program that reads a string (the password) as an input from

the user, makes a list of the characters from the input string (password),

and prints the list.

Sample Input 1:

penny06nebraska

Sample Output 1:

['p', 'e', 'n', 'n', 'y', '0', '6', 'n', 'e', 'b', 'r', 'a', 's', 'k', 'a']

Correct, you may enter


text=r'''Everyone has the following fundamental freedoms:

    (a) freedom of conscience and religion;

    (b) freedom of thought, belief, opinion and expression, including freedom of the press and other media of communication;

    (c) freedom of peaceful assembly; and

    (d) freedom of association.'''


import re

pattern = X

print(len(re.findall(pattern,text)))


LATEST TUTORIALS
APPROVED BY CLIENTS