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
A radio and communications security repairer is responsible for both radio and satellite communication systems.
natita [175]
I'm almost certain the answer is true
3 0
3 years ago
Read 2 more answers
Write a Coral program using integers userNum and x as input, and output userNum divided by x four times.
ss7ja [257]

Answer:

second_int = "Enter the second integer: "

usernum = int(input("Enter the first integer: "))

x = int(input(second_int))

usernum = usernum // x

print(usernum, end= ' ')

usernum = usernum // x

print(usernum, end= ' ')

usernum = usernum // x

print(usernum, end= ' ')

usernum = usernum // x

print(usernum)

Explanation:

im good

7 0
3 years ago
Please help me excel questions!​
Elenna [48]

Answer:

hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi,hi

7 0
3 years ago
Read 2 more answers
Rikki has had several problems at work recently. Her printer isn't printing correctly, copies from the copy machine come out wit
Ghella [55]
Create a maintenance schedule 
3 0
3 years ago
Read 2 more answers
Subscript numbering always starts at what value?
Leni [432]
It always starts with 0
4 0
3 years ago
Other questions:
  • We can see spreadsheet results graphically by creating:
    15·1 answer
  • Which of these statements about cell references is NOT true?
    10·2 answers
  • (1) The given program outputs a fixed-height triangle using a * character. Modify the given program to output a right triangle t
    6·1 answer
  • list six external parts or peripherals of a computer system and identify which are output and which are input devices
    8·1 answer
  • What is not a common purpose for a research report?
    5·2 answers
  • Select the correct answer.
    10·2 answers
  • What is the best platform for a online meeting?
    10·2 answers
  • Debug the recursive reverseString method, which is intended to return the input String str reversed (i.e. the same characters bu
    13·1 answer
  • DRAG DROP -A manager calls upon a tester to assist with diagnosing an issue within the following Python script:#!/usr/bin/python
    11·1 answer
  • What will the "background-color" of the "topButton" be when the program is finished running?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!