1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
BigorU [14]
3 years ago
6

. Write a function sumLastPart which, only using list library functions (no list comprehension), returns the sum of the last n n

umbers in the list, where n is the first argument to the function. (Assume that there are always at least n numbers in the list. For this problem and the others, assume that no error checking is necessary unless otherwise specified. But feel free to incorporoate error checking into your definition.) sumLastPart :: Int -> [Int] -> Int
Computers and Technology
1 answer:
max2010maxim [7]3 years ago
7 0

Answer:

In Python:

def sumLastPart(n,thelist):

   sumlast = 0

   lent = len(thelist)

   lastN = lent - n

   for i in range(lastN,lent):

       sumlast+=thelist[i]

   return sumlast

Explanation:

This defines the function

def sumLastPart(n,thelist):

This initializes the sum to 0

   sumlast = 0

This calculates the length of the list

   lent = len(thelist)

This calculates the index of the last n digit

   lastN = lent - n

This iterates through the list and adds up the last N digits

<em>    for i in range(lastN,lent):</em>

<em>        sumlast+=thelist[i]</em>

This returns the calculated sum

   return sumlast

You might be interested in
The first step in the information systems planning process is to ___________.
Basile [38]

Answer: Analyze the organization's strategic plan

Explanation:

 The initial step in the information system is to first analyze the strategic plan of the organization so that we can easily identify the main objective and challenge.

It is basically archived by enlisting the particular objective and function in the planning of information system in the organization.

All the remining option are involve in the remaining step of the information system planning not in the initial step.

Therefore, analyze the organization's strategic plan is correct as it is the first step of the information system planning.  

7 0
3 years ago
What term identifies a blank screen or animation that automatically displays on a computer monitor after a specified period of i
Sveta_85 [38]
The answer is a screensaver
5 0
3 years ago
How precisely can you rotate a graphic in a document?
Cloud [144]
Any picture of what our talking about
4 0
3 years ago
Please define processor​
fredd [130]
Processor means to break down something.
6 0
3 years ago
A(n) _____ is a flexible tool used to analyze data using reports that do not have a predetermined format.
Mandarinka [93]

Answer:

decision support system

Explanation:

4 0
3 years ago
Other questions:
  • Submit your 300-word essay describing the equipment usedI in a well-equipped studio’s audio department and the training and expe
    8·2 answers
  • When performing conflict management, it is important to identify your;
    6·1 answer
  • You have just installed a SOHO router in a customer's home and the owner has called to say his son is complaining that Internet
    5·1 answer
  • Using a single formatting _______ helps to make reading researched information easier; it lets the reader know what to expect.
    7·1 answer
  • Select the correct answer.
    7·1 answer
  • #include
    12·1 answer
  • As you continue to build the help desk, you want to ensure that all of the tools are in place and that the analysts have the too
    15·1 answer
  • 2. You are developing a new application that optimizes the processing of a warehouse’s operations. When the products arrive, the
    10·1 answer
  • If an occupation is projected to decline by 7% over the next 10 years, how would you rate the job outlook? (6 points)
    14·1 answer
  • what is the special feature of the view side by side command?adds additional columns in a worksheet at onceallows you to see two
    6·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!