Question

Asked Oct 17, 2019

27 views

Use the Design Recipe to write a function called **my_sum**** ** that consumes one parameter, assumed to be a *non-negative integer*. Return the sum of all integers between 0 and this number, inclusive. **Do ****not **use the built-in **sum** function. Include a docstring!

Write 3 **assertEqual** statements to test your function

Step 1

The python program obeys the following rubrics:

- Defining a function my_sum which accepts a parameter, assumed to be a non-negative integer.
- Declaring an integer variable sum whose values is equal to 0.
- Using a for loop in the my_sum function to calculate the sum of number.
- The range of for loop starts from 0 to num+1.
- Completing the function definition
- Now, displaying the message to user to enter the number.
- Calling my_sum function and displaying the sum.
- Use proper indentation to run the program successfully.

Step 2

**Program code in python: **

** **

'defining function with name'

def my_sum(number):

'declaring of integer variable sum=0'

sum=0

'using for loop, range of given for loop is 0 to num+1'

for j in range(0,number+1):

'calculating the total sum of values'

sum=sum+j

&nb...

Tagged in

Q: Fill in the blanks in the scheduling table. One schedule has been started for you. Each column repre...

A: FIFO (First in first out) scheduling algorithm is a non-preemptive algorithm which executes the proc...

Q: Develop a scenario with a series of logical statements that can be "solved" using kmaps. Once you h...

A: K-map is stand for Karnaugh map developed by Maurice Karnaugh at bell lab in 1953. The k- map is a g...

Q: Form boolean equations in POS and SOP forms from the truth table attached (PLEASE EXPLAIN ALL STEPS)...

A: The Boolean expression from the truth table can be converted into SOP form by:In the final equation ...

Q: In python Write a for loop (using the range() function) that will print the integers 10,15,20,25,30...

A: Program Instruction:Use range() function to start with 10 and end with 51 as range() function loops ...

Q: What are the Windows 2016 "flavors"?

A: Windows Server 2016 comes in 3 flavors, which are, Server Core (no GUI), Server with Desktop Experie...

Q: CHALLENGE 3.16.2: Alphabetic replace. ACTIVITY Replace any alphabetic character with ' in 2-characte...

A: Program://include the required header files#include <iostream>#include <string>#include ...

Q: Please explain all steps: Exercise 2: A) Suppose the main memory of the Pep/9 were completely filled...

A: A) The Pep/9 has 64K or 65,536 of bytes in the main memory and a unary instruction takes 1 byte. Hen...

Q: PLEASE EXPLAIN ALL STEPS: simplify the boolean equations: xz + (xy + ~z) ~xyz + yz + x~y

A: 1)xz + (xy + ~z)For simplifying the Boolean expression, use Karnaugh Map and follow the below steps-...

Q: A company that wants to send data over the Internet has asked you to write a program that will encry...

A: Following code, take the user's four-digit number as input using main method then it will call the e...