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
Write a converter program for temperatures. This program should prompt the user for a temperature in Celsius. It should then con
Aleksandr [31]

Answer:

c = float(input("Enter the temperature in Celsius: "))

f = c * 1.8 + 32

print("The temperature in Fahrenheit: " + str(f))

k = (f - 32) / 1.8 + 273.15

print("The temperature in Kelvin: " + str(k))

Explanation:

*The code is in Python.

Ask the user to enter the temperature in Celsius

Convert the Celsius to Fahrenheit using the conversion formula and print it

Convert the Fahrenheit to Kelvin using the conversion formula and print it

3 0
3 years ago
Jack wants to save his PowerPoint file electronically. He should store his file in:
Vikentia [17]

Answer:

C. USB

Explanation:

A USB Disk allows for a Backup of the PowerPoint file in case Jack needs it in the future.

3 0
3 years ago
Read 2 more answers
Alison is entering text in a Word document. As she is entering data, where will the cursor move in relation to the text she is t
Vinil7 [7]

The cursor should move right but if not give me more information to correct my statement

6 0
3 years ago
Online databases allow you access to material you may not be able to find when using popular search engines like Google. Select
Anna007 [38]

Answer:

True

Explanation:

6 0
3 years ago
What is one benefit of using electronic flash cards?
velikii [3]

Answer:

They can be searched using keywords. they may have a different alarm settings. they provide a personal organizer.

Explanation:

Hope this helped Mark BRAINLIEST!!!

4 0
3 years ago
Read 2 more answers
Other questions:
  • The specifications for ____ are developed by the world wide web consortium (w3c) and are continually evolving.
    13·1 answer
  • The analog signals that carry analog or digital data comprise composites built from combinations of simple sine waves.
    12·1 answer
  • Ned and mary ann are saving their files to a cd
    15·1 answer
  • Which of the given original work is protected by the copyright law
    9·1 answer
  • A hard drive cannot be partitioned until the device _________ is set.
    15·1 answer
  • Which device can be installed on the edge of your network to allow multiple remote users to connect securely to your internal en
    9·1 answer
  • Celeste is writing a paper. However, two pages in, her computer shuts down unexpectedly. She never saved her paper, and all her
    12·2 answers
  • What pointer appears when pointing to a hyperlink?
    9·1 answer
  • Your friend has a great idea for a new app, and she shows you a document that outlines what the app will do. This document is an
    6·1 answer
  • If a TextView has not been displayed yet, it is possible to retrieve measurements about its width and height using the _________
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!