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
How do you think Beyoncé choreography has/will influence the future of dance?
kaheart [24]

Answer: So choreographers do have the same rights as songwriters over the dissemination of their  skill, prestige, acclaim, power, visibility, popularity, influence, and potential  Will she find beauty in her 2019 forays in to Broadway

Explanation:

7 0
3 years ago
Read 2 more answers
__________ was awarded the Nobel Prize in physics forhis work on the photoelectric effect.
vekshin1

Answer:

Albert Einstein

Explanation:

Hello, great question. It is always good to ask questions and get rid of any doubts.

Albert Einstein was awarded the <u><em>Nobel Peace Prize</em></u> for his work on Photoelectric Effect in the year 1921. Albert Einstein was a physicist who was born in Germany in 1955, and dedicated his life to science. Largely known for his discovery of the <em><u>General Theory of Relativity</u></em>. Einstein won the Nobel Peace prize for discovering that light are formed in packets of energy that travel at in different frequencies or wave lengths.

I hope this answered your question. If you have any more questions feel free to ask away at Brainly.

8 0
3 years ago
Match each word to its correct meaning.
seropon [69]
1. goes to C.

2. goes to B.

3. goes to A.
6 0
3 years ago
Convert 12 bits to bytes​
Genrish500 [490]

Answer:

1.5 bytes

Explanation:

I byte = 8 bit ....

3 0
2 years ago
How to print<br> 1<br> 321<br> 54321<br> 7654321<br> triangle pattern in python
krok68 [10]

Hope this helps, Upvote if you like it :)

6 0
2 years ago
Other questions:
  • PLEASE HURRY
    6·1 answer
  • PLEASE HELP, True or False: The term whitespace speaks to the design of a website
    8·2 answers
  • Dillard’s wants to learn about its consumers' attitudes toward online purchases. There are numerous studies that are available a
    9·1 answer
  • Use HTML to create a web page
    10·1 answer
  • A user has just reported that he downloaded a file from a prospective client using IM. The user indicates that the file was call
    11·1 answer
  • Which of the following translates packets so that the node can understand them once they enter through a port?
    5·2 answers
  • In the following code: function drawCircle(radius, x, y, color) { var circle = new Circle(radius); circle.setPosition(x, y); cir
    7·1 answer
  • What is the best way to improve an online search?
    11·2 answers
  • Which feature of REPL.it would you use to transmit your program to a friend?
    12·1 answer
  • What is the function of ALU? <br>​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!