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]
2 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]2 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 program whose input is two integers, and whose output is the first integer and subsequent increments of 5 as long as the
Anna11 [10]

Answer:

The program in Python is as follows:

num1 = int(input())

num2 = int(input())

if num2 < num1:

   print("Second integer can't be less than the first.")

else:

   for i in range(num1,num2+1,5):

       print(i,end=" ")

Explanation:

This gets the first integer from the user

num1 = int(input())

This gets the second integer from the user

num2 = int(input())

If the second is less than the first, the following prompt is printed

<em>if num2 < num1:</em>

<em>    print("Second integer can't be less than the first.")</em>

If otherwise, the number between the intervals is printed with an increment of 5

<em>else:</em>

<em>    for i in range(num1,num2+1,5):</em>

<em>        print(i,end=" ")</em>

<em />

6 0
2 years ago
When individuals are purchasing a computer, they sometimes might get the most expensive computer they can afford. Why might this
timama [110]

Answer:

Expensive is not always better

Explanation:

So I build 2 computers ok

Computer 1: Price 1,999$

<u>Whats Included:</u>

  • Antivirus
  • Anti-Over-Heat
  • Windows 8 Operating Software
  • Free VPN (For Life)
  • 24/7 Support
  • 1 year warranty
  • 3/5 Star Reviews | Main Review Type: Parts Breaking Inside

Computer 2: Price 799$

<u>Whats Included:</u>

  • Anti Virus
  • Anti Over-Heat
  • 1 Year Warranty
  • Windows 10 Operating Software
  • 24/7 Support
  • 10 Year Warranty
  • 4/5 Star Reviews | Main Review Type: Runs Smooth
  • No VPN

<h2>So Computer 2 Has better reviews and a 10 year warranty over computer 1's 1 year warranty</h2>
8 0
2 years ago
Before a program written in c can be executed on a computer, what step is required to be done first?
sergejj [24]
It should be compiled. It won't work if it's not compiled.
6 0
3 years ago
Alternating Current or AC is better for use in ___________, while DC direct current is needed in _________ .
PIT_PIT [208]
<span>C electric power transmisson and electronics</span>
6 0
2 years ago
Read 2 more answers
Implication of technological literacy to a teacher training today
Dafna1 [17]

<u>Implication of technological literacy to a teacher training today :</u>

  • First of training has to be under technology literacy before training starts. Trainer also should have enough knowledge on technology literacy.
  • Trainer can take printed materials to share the document on the topic which to be covered and circulated to trainers
  • Since it given as general topic, training teacher has to cover the following topic, general on computer and purpose of computer today's life, life cycle of computer grown from old PC to laptop and tablet.
  • Next topic such be covered operating system and explain about the operating system and different technology is used.
  • Revolution on technology should be also covered and explained in details.
8 0
3 years ago
Other questions:
  • ___ is a career discipline focusing on helping companies use computer technology effectively.
    12·1 answer
  • How much does a Canon PowerShot G7X cost in America?
    14·1 answer
  • It proceeds the statement causes execution of the current loop iteration to end and commence at the beginning of the next loop.
    10·1 answer
  • While interoperability and unrestricted connectivity is an important trend in networking, the reality is that many diverse syste
    12·1 answer
  • Employers will check you out on social media sites like Facebook, MySpace, and Twitter.
    6·2 answers
  • Who is gossip girl.....
    8·2 answers
  • Help please
    13·2 answers
  • The arrows in this question indicated the determination of two attributes. For example, the arrow that goes ProductID to Product
    11·1 answer
  • Many bookstores have closed since the rise of the Internet. What type of
    11·1 answer
  • Maria is conducting a security investigation and has identified a suspect. The suspect is an employee of the organization who ha
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!