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
andrew11 [14]
3 years ago
7

Design a program that asks the user to enter a string containing a series of single digit numbers with nothing separating them.

The program should display the sum of all the single digit numbers in the string. For example, if the user enters 2514, the method should return 12, which is the sum of 2, 5, 1, and 4. (Hint: The stringToInteger library function can be used to convert a single character to an integer.)
Computers and Technology
1 answer:
ruslelena [56]3 years ago
7 0

Answer:

  1. def calcSum(d):
  2.    sum = 0
  3.    for x in d:
  4.        sum += int(x)
  5.    return sum
  6. digits = input("Please enter your digits: ")
  7. print(calcSum(digits))

Explanation:

The solution code is written in Python.

Firstly, create a function that take one input digit string (Line 1).

In the function, create a sum variable with initial value 0.

Use a for loop to traverse through each character in the digit string and in the loop use int method to convert each character to integer and add it to sum variable (Line 3-5) and return the sum as output.

Next, use input function to prompt user enter a digit string (Line 7).

Lastly test the function by passing the input digit as argument and print the result (Line 8).

You might be interested in
How to send an email to multiple recipients individually.
zheka24 [161]

Answer:

The BCC method

Explanation:

4 0
2 years ago
Create a list words = ['is', 'NLP', 'fun', '?']. Use a series of assignment statements (e.g. words[1] = words[2]) and a temporar
Svetlanka [38]

Answer:

words = ['is', 'NLP', 'fun', '?']

tmp = words[1]

words[1] = words[0]

words[0] = tmp

words[3] = '!'

print(words)

Explanation:

- Create the list

- Assign the new values using <em>tmp</em> variable

- Print the result

Since tuples in Python are unchangeable, you cannot transform the list using tuple assignment.

5 0
2 years ago
((Excel)) please help, 100 points, and brain crown thingy, not only that, i will make several of these so you can get several hu
cupoosta [38]

Answer:

First you read the question and numbers, then you use the numbers in the correct way and you try reallllyyy hard, you will find your answer! Hope this helps! :D

4 0
2 years ago
What is the check digit for the following original product number: 140501941 ? *
Natasha_Volkova [10]

Explanation:

I think it is 7, but I could be wrong..... sorry

8 0
2 years ago
Read 2 more answers
(50 points) What animes should I watch?
Eddi Din [679]

Answer:

naruto,naruto shippuden and baruto

Explanation:

3 0
3 years ago
Read 2 more answers
Other questions:
  • Brenda's working on improving a Google Search Ads quality score so it potentially gets a better ad rank and performs better in t
    9·1 answer
  • Which are malicious codes? <br><br> JavaScript <br> Key loggers <br> Scrum <br> Spyware <br> Worms
    12·1 answer
  • Enzo formed a study group for an upcoming geography test. To start off each session, they go over past notes and look at maps. T
    14·1 answer
  • What is an internal node?
    11·1 answer
  • Having data in a column formatted differently based on value is known as
    7·1 answer
  • Cite an early photographic pioneer or invention. Explain their/its impact on photography as we know it today.
    14·1 answer
  • 1. why is manufacturing considered the biggest contributor to progress
    9·1 answer
  • With
    10·2 answers
  • Where is the flash drive listed in a windows 7 save as dialog box?
    9·1 answer
  • Frequently used _____________ can be saved as _____________ for use in analysis, dashboards, reports, tickets, and alerts.
    8·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!