Define a function named add

Assignment Help Basic Computer Science
Reference no: EM132183933

Define a function named add_from_one_again(st) which receives a list containing digits only (at least one digit, and all digits >0, no need to validate)  and returns a number as illustrated by the following examples

When the list is 

[5,2,3]

the resulting number should be:

(1+2+3+4+5) + (1+2) + (1+2+3)  = 24

When the list is 

[3,2,5]

the resulting number should be:

(1+2+3) + (1+2) + (1+2+3+4+5) = 24

When the list is

[4,2,2]

the resulting number should be:

(1+2+3+4) + (1+2) + (1+2) = 16

As an example, the following code fragment:

lst = [5,2,3]

print(add_from_one_again(lst))

should produce the output:

24

Language: python

I have this so far, but doesn't work:

def add_from_one_again(st):

collect_sum = 0

for i in st:

i = int(i)

collect_sum += sum(len(i))

return collect_sum

Reference no: EM132183933

Questions Cloud

How can a person protect the privacy in the digital world : Cyberstalking can take place through any form of electronic communication, to include email, cell phones (text messaging), social network sites.
What are the current generational differences in attitudes : Based on Internet research of reputable sources, what are the current generational differences in attitudes toward the role of religion in America?
What are the three types of sparklines options : In this Week's reading and prep work, you learned about the Sparklines feature in Excel. What are the three types of Sparklines options in Excel.
Construct a quarterly binomial model : The stock has an expected return of 8% per year and return volatility of 20% per year. Construct a 2-period quarterly binomial model for the stock
Define a function named add : Define a function named add_from_one_again(st) which receives a list containing digits only (at least one digit, and all digits >0, no need to validate)
Employer dress code impact the organizational culture : What is your employer’s dress code? How does an employer’s dress code impact the organizational culture?
Prepare financial statements of small and medium scale : MAA261 - Financial Accounting - prepare financial statements of small and medium scale business - Understand the nature of the accounting information systems
How does quantum cryptography work : Compare and contrast quantum cryptography and traditional cryptography. How does quantum cryptography work?
What amount must joyce include in gross income for december : Joyce is self-employed. She uses the calendar year and the cash method of accounting. What amount must Joyce include in gross income for December

Reviews

Write a Review

Basic Computer Science Questions & Answers

  Identifies the cost of computer

identifies the cost of computer components to configure a computer system (including all peripheral devices where needed) for use in one of the following four situations:

  Input devices

Compare how the gestures data is generated and represented for interpretation in each of the following input devices. In your comparison, consider the data formats (radio waves, electrical signal, sound, etc.), device drivers, operating systems suppo..

  Cores on computer systems

Assignment : Cores on Computer Systems:  Differentiate between multiprocessor systems and many-core systems in terms of power efficiency, cost benefit analysis, instructions processing efficiency, and packaging form factors.

  Prepare an annual budget in an excel spreadsheet

Prepare working solutions in Excel that will manage the annual budget

  Write a research paper in relation to a software design

Research paper in relation to a Software Design related topic

  Describe the forest, domain, ou, and trust configuration

Describe the forest, domain, OU, and trust configuration for Bluesky. Include a chart or diagram of the current configuration. Currently Bluesky has a single domain and default OU structure.

  Construct a truth table for the boolean expression

Construct a truth table for the Boolean expressions ABC + A'B'C' ABC + AB'C' + A'B'C' A(BC' + B'C)

  Evaluate the cost of materials

Evaluate the cost of materials

  The marie simulator

Depending on how comfortable you are with using the MARIE simulator after reading

  What is the main advantage of using master pages

What is the main advantage of using master pages. Explain the purpose and advantage of using styles.

  Describe the three fundamental models of distributed systems

Explain the two approaches to packet delivery by the network layer in Distributed Systems. Describe the three fundamental models of Distributed Systems

  Distinguish between caching and buffering

Distinguish between caching and buffering The failure model defines the ways in which failure may occur in order to provide an understanding of the effects of failure. Give one type of failure with a brief description of the failure

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd