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

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

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