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
You need to update your router settings, so you log into the administration panel, Whose Internet protocol (IP) address is 192.1
devlian [24]

Answer:

D

Explanation:

5 0
3 years ago
The function ________ comprises one or more statements that are executed when the function is called.
spin [16.1K]

Answer:

Option B(Body) is the correct answer for the above question.

Explanation:

The function is a defined processor of some specific task, which is used to perform some action of the task. The function is of two types one is predefined, which is defined by the compiler and, the other is user-defined, which is defined by the programmer. Any user-defined function has three parts--

  • Function prototype: It states the type of function.
  • Function body: It holds the collection of instruction that needs to perform by the function.
  • Function call: From where the function is called.

The above question asked about the term, which holds the statement of the function and that term is function Body, which is defined above. So the answer body, which is stated from the option 'B'. Hence 'B', is the correct option while the other is not because--

  • Option 'A' states about the header, which is not the part of the function
  • Option 'C' states about data type, which defines the types of data.
  • Option 'D' states none of these, but the answer is option B.
  • Option 'E' states about the definition, which is not the correct answer.
5 0
3 years ago
When creating a document template, you can either start from an existing document or begin from _____.
Anna35 [415]
A new blank document
7 0
3 years ago
Which application software would be most suitable for writing a resume?
Gemiola [76]

Answer:

Either word or I would suggest using google docs and word and compare.

Explanation:

You can set up a resume in word.

7 0
3 years ago
What is Network Address Translation (NAT) and how does it work in a network?
Allisa [31]

Answer:

 Network address translation (NAT) is a method for designing the IP address and it basically operate on router. NAT usually connect two network together and translate the unique and private address into the legal address.

Network address translation is a technique that works in network  for re-mapping the IP address into another by modify the network address information into the IP packet header. NAT gateway are used for the entire private network.  

The network address translation use both the security and economical purpose in an organization to limit the public IP address.

5 0
3 years ago
Other questions:
  • How can you tell that a rolling soccer ball is in motion
    5·1 answer
  • How are blogs and wiki alike
    15·2 answers
  • To which built-in object does the function sin(x) belong?
    12·1 answer
  • Compose one paragraph (three to four sentences) explaining the difference between a courtesy copy and a blind courtesy copy (thi
    9·1 answer
  • What function key is used to enable the spelling and grammar function
    14·1 answer
  • How would asking questions or defining problems be used in this career?<br> -
    13·1 answer
  • If you would like to give another user permissions on your mailbox or to particular folders within your mailbox, which
    7·2 answers
  • Q. Describe the T.V. as an ICT tool.​
    13·1 answer
  • IBM’s system that is built on the middle ground approach to AI.
    12·1 answer
  • Show the B-tree that results when inserting R,Y,F,X,A,M,C,D,E,T,H,V,L,W,G (in that order)branching factor oft= 3. You need only
    11·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!