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

  Loan from biggles bank

Ron and Robin Reid wish to borrow $540,000 to buy a home. The loan from Biggles Bank requires equal monthly repayments over 20 years

  Difference between the = symbol in java and in mathematics

Explain the difference between the = symbol in Java and in mathematics.

  Buffer objects of varying sizes

Suppose we want to store in the buffer objects of varying sizes, and varying read costs (such as Web pages, whose read cost depends on the site from which they are fetched). Suggest how a buffer manager may choose which block to evict from the buf..

  How does the performance change in the absence

how does the performance change in the absence of barrier synchronization?

  Discussion-hierarchical file systems

Every operating system needs a file system to save and retrieve data. Most file systems have various strengths and weakness associated with flexibility, reliability, performance, scalability, security, and fault tolerance. Various types of file sy..

  Discuss backup plans and any devices that you use

In this week's discussion, discuss what you think you should do to protect your work on the computer. Discuss backup plans and any devices that you use for the backup of your information.

  Cause the price to be set to zero

Any other entered size invalid and should cause the price to be set to zero.

  Determine the type of cache memory

From the e-Activity, determine the type of cache memory (i.e., Level 1, Level 2, or another type) that resides on a computer

  Explain how these challenges can be addressed

What are the challenges that enterprise applications pose and how are enterprise applications taking advantage of new technologies?

  Display a message saying the date is not magic

The date June 10, 1960 is special because when we write it in the following format, the month times the day equals the year.6/10/60

  Create application to declares array of ten houseplant

Design an application that declares an array of 10 HousePlants. Prompt the user for data for each of the HousePlants, then display all values.

  Do the hunters remain in the simulation throughout

What other classes required changing as a result of introducing hunters? Is there a need to introduce further decoupling to the classes?

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