python hw

n PyCharm, write a function in a module to compute the factorial of a number using a while loop.

  • factorial(-1) = invalid
  • factorial(0) = 1
  • factorial(1) = 1*1 = 1
  • factorial(2) = 2*1*1 = 2
  • factorial(3) = 3*2*1*1 = 6
  • factorial(4) = 4*3*2*1*1 = 24

Call your factorial function with inputs equal to 0, 1, 2, 5, and -2.

Comment your code, including module and function docstrings, and test for PEP8 compliance.

Click on the print icon in your PyCharm console and save the output as console.pdf

Submit your .py files and console.pdf in Canvas.

Rubric (100 points):

- (20 points) The correct files are submitted. Files have meaningful names. Each block of code is in the correct file.

- (20 points) Each Python file provides thorough comments, including module and function docstrings. Code and comments are PEP8-compliant.

- (20 points) Only structures covered so far are used. Functions, parameters, and types are used properly. Unnecessary structures, global variables, hard-coded values, break, and continue are not used. Code is clean and lean.

- (20 points) The printout shows that the code returns the correct values and messages for the valid test values and the correct error messages for the invalid test values.

- (20 points) The function calls are located in a different file than the module file and cover all cases listed in the instructions. We encourage students to create additional tests, but will not grade them.

Get Help With a similar task to - python hw

Login to view and/or buy answers.. or post an answer

Related Questions

Similar orders to python hw
7
Views
0
Answers
Java Customer Program
Problem 1: Customer Max has opened his own pet supply store so he can help himself to treats and toys whenever he wishes. In order to encourage customers to shop at his store more, he is implementing a customer loyalty program. For every $100 spent, the c...
11
Views
0
Answers
Literature Review for Smart Case for tracking monitoring and tracing packages being delivered
They're three attachments below one being the handbook to help guidance during this progress another being the first proposal of the project and then the assignment that needs completing, the Literature review....
15
Views
0
Answers
c++ lab 1 intro lab
P ROBLEM STATEMENT: A review and extension of cs132: sort a file with 120 records. However, due to memory restrictions only 20 records may be placed into memory. You are to implement a “quasi” external sort CODE/DIRECTIONS: For the sake of si...
19
Views
0
Answers
Cryptography Assignment C
1. Write two programs that use some of the build-in Cryptographic APIs a. Write one C program that uses Symmetric-Key algorithm b. Write one C program that used Asymmetric-key algorithm c. Use C programming language to write your code d. Make sure tha...