Which consists of four averages:

Assignment Help Basic Computer Science
Reference no: EM13966212

Question:

def sma(list1,n):

"""Returns simple moving average of a list of numbers in size n"""

count = 0

result = [0]*(len(list1)-n+1)

for item in range(len(result)):

result[count] = arithmetic_mean(list1[count:count+n])

count += 1

print count

return result

why is this code not working? (python)  I dont think the for loop is going through because counter never goes off 1.

For example, sma([5, 2, 8, 3, 7, 4], 3) should return [5, 4.3333333, 6, 4.666667], which consists of four averages: (5+2+8)/3, (2+8+3)/3, (8+3+7)/3, and (3+7+4)/3. Note that if the length of the input list is less than or equal to n, then the result list contains just one number, the list's mean.

Reference no: EM13966212

Questions Cloud

What is stress and what are stressors : What is stress? What are stressors? Can stress be good? Describe the difference between a Type A and Type B personality? Which are you? Which would you prefer to manage? Why?
Plant assets and depreciation methods problem : Century Company negotiated a lump-sum purchase of several assets from a contractor who was retiring.PLANT ASSETS AND DEPRECIATION METHODS PROBLEM
Business is worth more than the price of its stock : Jorge makes the comment that a "business is worth more than the price of its stock. 'He is of course referring to the family values and social value of the firm.(Ignore this).
Interview questions-describe a humbling experience : Describe a humbling experience. You seem pretty positive, what types of things bring you down? Why should we hire you? Describe yourself, what excites you?
Which consists of four averages: : Why is this code not working? (python)  I dont think the for loop is going through because counter never goes off 1. For example, sma([5, 2, 8, 3, 7, 4], 3) should return [5, 4.3333333, 6, 4.666667], which consists of four averages: (5+2+8)/3, (2+8+3..
Budgeted production of mink caress : Two grams of musk oil are required for each bottle of Mink Caress, a very popular perfume made by a small company in western Siberia. The cost of the musk oil is $1.70 per gram. Budgeted production of Mink Caress is given below by quarters for Year 2..
Determining the least-squares line appropriate : An experiment was conducted to observe the effect of an increase in temperature on the potency of an antibiotic. Three one ounce portions of the antibiotic were stored for equal lengths of time at each of the following Fahrenheit temperatures: 40?..
What is involved in project scope management : Briefly describe what happens in each of the five project management process groups (initiating, planning, executing, monitoring and controlling, and closing). What types of activities are done before initiating a project? What is involved in project..
What is the angular frequency : Let sin(α) = cos(α+β). Expand cos(α+β) with the appropriate trigonometric angle addition formula and find a value for β. Let cos(α) = sin(α+β). Expand sin(α+β) with the appropriate trigonometric angle addition formula and find a value for β.

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Write a java program for performing order matching

write a Java program for performing order matching according to the typical rules of a double auction system.

  What is inheritance

A. What is inheritance ?B.  What are different forms of inheritance?C. Give one example of single level inheritance in C++

  How the organisation has used is-it to address

how the organisation has used IS/IT to address and service its' market, not just on the products it provides.

  Flexible solution for the consultants

What will adding a flexible solution for the consultants to connect to the network do to this risk model? What are some safeguards that can be implemented to reduce the risk?

  Determine the date in opening the letter from same file

if /home/jenny/draft and /home/Alex/letter are relates to same file and the following sequence of events occurs, determine the date in opening the letter?

  How can they be resolved explain

What are some of the typical problems a project team may encounter during a project's life cycle? How can they be resolved? Explain.

  Identify scholarly work

In this assignment, you will research and identify scholarly work that you can use to support your research.

  Create memo for management-accounting information systems

Create a memo to your management in which you address significance of accounting information systems. Give some main features of accounting information system.

  Identify the system high and system low

Draw a lattice of a 2-element set ordered by inclusion.

  Software development life cycle

Literature Review - 3-4 pages Take the paper to next level. Identify about 15 scholarly articles using VIU library resources as related to your topic, extract information as needed and blend the content into your paper with suitable sections

  Show process that allow implementation of stack

You will now look at Stacks and Queues using linked lists. Complete the following for this question:

  Which technology half or full duplex has a lower effective

Which technology (half or full duplex) has a lower effective throughput rate

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd